home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / GCC 1.37.1r14 / usr / gcc-1.37.1r14 / (gcc-1.37.π) / md < prev    next >
Encoding:
Text File  |  1993-10-05  |  103.0 KB  |  3,716 lines  |  [TEXT/KAHL]

  1. ;;- Machine description for GNU compiler
  2. ;;- Motorola 68000/Macintosh Version, extensively modified from the
  3. ;;  generic 68000 description.
  4. ;;   Copyright (C) 1987 Free Software Foundation, Inc.
  5. ;;   Copyright (C) 1989, 1990 Apple Computer, Inc.
  6.  
  7. ;; This file is part of GNU CC.
  8.  
  9. ;; GNU CC is free software; you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 1, or (at your option)
  12. ;; any later version.
  13.  
  14. ;; GNU CC is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ;; GNU General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with GNU CC; see the file COPYING.  If not, write to
  21. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. ;; The Macintosh-specific changes lie in several areas: removal of the FPA
  24. ;; support to save space, addition of SANE support, alterations to asm
  25. ;; syntax to be appropriate to the MPW assembler, and a number of small
  26. ;; mods.
  27.  
  28. ;;- instruction definitions
  29.  
  30. ;;- @@The original PO technology requires these to be ordered by speed,
  31. ;;- @@    so that assigner will pick the fastest.
  32.  
  33. ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  34.  
  35. ;;- When naming insn's (operand 0 of define_insn) be careful about using
  36. ;;- names from other targets machine descriptions.
  37.  
  38. ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
  39. ;;- updates for most instructions.
  40.  
  41. ;;- Operand classes for the register allocator:
  42. ;;- 'a' one of the address registers can be used.
  43. ;;- 'd' one of the data registers can be used.
  44. ;;- 'f' one of the m68881 registers can be used
  45. ;;- 'r' either a data or an address register can be used.
  46.  
  47. ;;- Immediate Floating point operator constraints
  48. ;;- 'G' a floating point constant that is *NOT* one of the standard
  49. ;;   68881 constant values (to force calling output_move_const_double
  50. ;;   to get it from rom if it is a 68881 constant).
  51. ;;
  52. ;;   See the functions standard_XXX_constant_p in output-m68k.c for more
  53. ;; info.
  54.  
  55. ;;- Immedidate integer operands Constrains:
  56. ;;- 'I'  1 .. 8
  57. ;;- 'J'  -32768 .. 32767
  58. ;;- 'K'  -128 .. 127
  59. ;;- 'L'  -8 .. -1
  60.  
  61. ;;- Some of these insn's are composites of several m68000 op codes.
  62. ;;- The assembler (or final @@??) insures that the appropriate one is
  63. ;;- selected.
  64.  
  65. ;; why are these here and what are they for?
  66. (define_insn ""
  67.   [(set (match_operand:DF 0 "push_operand" "=m")
  68.     (match_operand:DF 1 "general_operand" "ro<>fF"))]
  69.   ""
  70.   "*
  71. {
  72.   if (FP_REG_P (operands[1]))
  73.     return \"fmove%.d %1,%0\";
  74.   return output_move_double (operands);
  75. }")
  76.  
  77. (define_insn ""
  78.   [(set (match_operand:DI 0 "push_operand" "=m")
  79.     (match_operand:DI 1 "general_operand" "ro<>F"))]
  80.   ""
  81.   "*
  82. {
  83.   return output_move_double (operands);
  84. }")
  85.  
  86. (define_insn "tstsi"
  87.   [(set (cc0)
  88.     (match_operand:SI 0 "general_operand" "rm"))]
  89.   ""
  90.   "*
  91. {
  92.   if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  93.     return \"tst%.l %0\";
  94.   /* If you think that the 68020 does not support tstl a0,
  95.      reread page B-167 of the 68020 manual more carefully.  */
  96.   /* On an address reg, cmpw may replace cmpl.  */
  97.   return \"cmp%.w #0,%0\";
  98. }")
  99.  
  100. (define_insn "tsthi"
  101.   [(set (cc0)
  102.     (match_operand:HI 0 "general_operand" "rm"))]
  103.   ""
  104.   "*
  105. {
  106.   if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  107.     return \"tst%.w %0\";
  108.   return \"cmp%.w #0,%0\";
  109. }")
  110.  
  111. (define_insn "tstqi"
  112.   [(set (cc0)
  113.     (match_operand:QI 0 "general_operand" "dm"))]
  114.   ""
  115.   "tst%.b %0")
  116.   
  117. (define_expand "tstsf"
  118.   [(set (cc0)
  119.     (match_operand:SF 0 "general_operand" ""))]
  120.   "TARGET_SANE || TARGET_68881"
  121.   "")
  122.  
  123. (define_insn ""
  124.   [(set (cc0)
  125.     (match_operand:SF 0 "general_operand" "fdm"))]
  126.   "TARGET_68881"
  127.   "*
  128. {
  129.   cc_status.flags = CC_IN_68881;
  130.   if (FP_REG_P (operands[0]))
  131.     return TARGET_GAS?\"ftst%.x %0\":\"ftest%.x %0\";
  132.   return TARGET_GAS?\"ftst%.s %0\":\"ftest%.s %0\";
  133. }")
  134.  
  135. (define_insn ""
  136.   [(set (cc0)
  137.     (match_operand:SF 0 "general_operand" "ro"))]
  138.   "TARGET_SANE"
  139.   "* return output_sane_tst (operands, 0x1008, \"FCMPS\");")
  140.  
  141. (define_expand "tstdf"
  142.   [(set (cc0)
  143.     (match_operand:DF 0 "general_operand" ""))]
  144.   "TARGET_SANE || TARGET_68881"
  145.   "")
  146.  
  147. (define_insn ""
  148.   [(set (cc0)
  149.     (match_operand:DF 0 "general_operand" "fm"))]
  150.   "TARGET_68881"
  151.   "*
  152. {
  153.   cc_status.flags = CC_IN_68881;
  154.   if (FP_REG_P (operands[0]))
  155.     return TARGET_GAS?\"ftst%.x %0\":\"ftest%.x %0\";
  156.   return TARGET_GAS?\"ftst%.d %0\":\"ftest%.d %0\";
  157. }")
  158.  
  159. (define_insn ""
  160.   [(set (cc0)
  161.     (match_operand:DF 0 "general_operand" "ro"))]
  162.   "TARGET_SANE"
  163.   "* return output_sane_tst (operands, 0x0808, \"FCMPD\");")
  164.  
  165. (define_expand "tstxf"
  166.   [(set (cc0)
  167.     (match_operand:XF 0 "general_operand" ""))]
  168.   "TARGET_SANE || TARGET_68881"
  169.   "")
  170.  
  171. (define_insn ""
  172.   [(set (cc0)
  173.     (match_operand:XF 0 "general_operand" "f"))]
  174.   "TARGET_68881"
  175.   "*
  176. {
  177.   cc_status.flags = CC_IN_68881;
  178.   return TARGET_GAS?\"ftst%.x %0\":\"ftest%.x %0\";
  179. }")
  180.  
  181. (define_insn ""
  182.   [(set (cc0)
  183.     (match_operand:XF 0 "general_operand" "ro"))]
  184.   "TARGET_SANE"
  185.   "* return output_sane_tst (operands, 0x0008, \"FCMPX\");")
  186.  
  187. ;; compare instructions.
  188.  
  189. ;; A composite of the cmp, cmpa, & cmpi m68000 op codes.
  190. ;; We use d*a in the constraints because compares with data regs are faster.
  191. (define_insn "cmpsi"
  192.   [(set (cc0)
  193.     (compare (match_operand:SI 0 "general_operand" "rM,mr,>")
  194.          (match_operand:SI 1 "general_operand" "mr,Mr,>")))]
  195.   ""
  196.   "*
  197. {
  198.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  199.     return \"cmpm%.l %1,%0\";
  200.   if (REG_P (operands[1])
  201.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  202.     { cc_status.flags |= CC_REVERSED;
  203.       return \"cmp%.l %d0,%d1\"; 
  204.     }
  205.   return \"cmp%.l %d1,%d0\";
  206. }")
  207.  
  208. (define_insn "cmphi"
  209.   [(set (cc0)
  210.     (compare (match_operand:HI 0 "general_operand" "rnm,d,n,m")
  211.          (match_operand:HI 1 "general_operand" "d,rnm,m,n")))]
  212.   ""
  213.   "*
  214. {
  215.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  216.     return \"cmpm%.w %1,%0\";
  217.   if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
  218.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  219.     { cc_status.flags |= CC_REVERSED;
  220.       return \"cmp%.w %d0,%d1\"; 
  221.     }
  222.   return \"cmp%.w %d1,%d0\";
  223. }")
  224.  
  225. (define_insn "cmpqi"
  226.   [(set (cc0)
  227.     (compare (match_operand:QI 0 "general_operand" "dn,d,m,>")
  228.          (match_operand:QI 1 "general_operand" "dm,nd,d,>")))]
  229.   ""
  230.   "*
  231. {
  232.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  233.     return \"cmpm%.b %1,%0\";
  234.   if (REG_P (operands[1])
  235.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  236.     { cc_status.flags |= CC_REVERSED;
  237.       return \"cmp%.b %d0,%d1\";
  238.     }
  239.   return \"cmp%.b %d1,%d0\";
  240. }")
  241.  
  242. (define_expand "cmpsf"
  243.   [(set (cc0)
  244.     (compare (match_operand:SF 0 "general_operand" "")
  245.          (match_operand:SF 1 "general_operand" "")))]
  246.   "TARGET_SANE || TARGET_68881"
  247.   "")
  248.  
  249. (define_insn ""
  250.   [(set (cc0)
  251.     (compare (match_operand:SF 0 "general_operand" "f,mdG")
  252.          (match_operand:SF 1 "general_operand" "fmdG,f")))]
  253.   "TARGET_68881"
  254.   "*
  255. {
  256.   cc_status.flags = CC_IN_68881;
  257.   if (FP_REG_P (operands[0]))
  258.     {
  259.       if (FP_REG_P (operands[1]))
  260.     return \"fcmp%.x %1,%0\";
  261.       else
  262.         return \"fcmp%.s%1,%0\";
  263.     }
  264.   cc_status.flags |= CC_REVERSED;
  265.   return \"fcmp%.s%0,%1\";
  266. }")
  267.  
  268. (define_insn ""
  269.   [(set (cc0)
  270.     (compare (match_operand:SF 0 "general_operand" "ro")
  271.          (match_operand:SF 1 "general_operand" "ro")))]
  272.   "TARGET_SANE"
  273.   "* return output_sane_cmp (operands, 0x1008, \"FCMPS\");")
  274.  
  275. (define_expand "cmpdf"
  276.   [(set (cc0)
  277.     (compare (match_operand:DF 0 "general_operand" "")
  278.          (match_operand:DF 1 "general_operand" "")))]
  279.   "TARGET_SANE || TARGET_68881"
  280.   "")
  281.  
  282. (define_insn ""
  283.   [(set (cc0)
  284.     (compare (match_operand:DF 0 "general_operand" "f,mG")
  285.          (match_operand:DF 1 "general_operand" "fmG,f")))]
  286.   "TARGET_68881"
  287.   "*
  288. {
  289.   cc_status.flags = CC_IN_68881;
  290.   if (FP_REG_P (operands[0]))
  291.     {
  292.       if (FP_REG_P (operands[1]))
  293.     return \"fcmp%.x %1,%0\";
  294.       else
  295.         return \"fcmp%.d %1,%0\";
  296.     }
  297.   cc_status.flags |= CC_REVERSED;
  298.   return \"fcmp%.d %0,%1\";
  299. }")
  300.  
  301. (define_insn ""
  302.   [(set (cc0)
  303.     (compare (match_operand:DF 0 "general_operand" "ro")
  304.          (match_operand:DF 1 "general_operand" "ro")))]
  305.   "TARGET_SANE"
  306.   "* return output_sane_cmp (operands, 0x0808, \"FCMPD\");")
  307.  
  308. (define_expand "cmpxf"
  309.   [(set (cc0)
  310.     (compare (match_operand:XF 0 "general_operand" "")
  311.          (match_operand:XF 1 "general_operand" "")))]
  312.   "TARGET_SANE || TARGET_68881"
  313.   "")
  314.  
  315. (define_insn ""
  316.   [(set (cc0)
  317.     (compare (match_operand:XF 0 "general_operand" "f,mG")
  318.          (match_operand:XF 1 "general_operand" "fmG,f")))]
  319.   "TARGET_68881"
  320.   "*
  321. {
  322.   cc_status.flags = CC_IN_68881; 
  323.   if (REG_P (operands[0]))
  324.     return \"fcmp%.x %1,%0\";
  325.   cc_status.flags |= CC_REVERSED;
  326.   return \"fcmp%.x %0,%1\";
  327. }")
  328.  
  329. (define_insn ""
  330.   [(set (cc0)
  331.     (compare (match_operand:XF 0 "general_operand" "ro")
  332.          (match_operand:XF 1 "general_operand" "ro")))]
  333.   "TARGET_SANE"
  334.   "* return output_sane_cmp(operands, 0x0008, \"FCMPX\");")
  335.  
  336. ;; Recognizers for btst instructions.
  337.  
  338. (define_insn ""
  339.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do")
  340.                 (const_int 1)
  341.                 (minus:SI (const_int 7)
  342.                       (match_operand:SI 1 "general_operand" "di"))))]
  343.   ""
  344.   "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
  345.  
  346. (define_insn ""
  347.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d")
  348.                 (const_int 1)
  349.                 (minus:SI (const_int 31)
  350.                       (match_operand:SI 1 "general_operand" "di"))))]
  351.   ""
  352.   "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
  353.  
  354. ;; The following two patterns are like the previous two
  355. ;; except that they use the fact that bit-number operands
  356. ;; are automatically masked to 3 or 5 bits.
  357.  
  358. (define_insn ""
  359.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do")
  360.                 (const_int 1)
  361.                 (minus:SI (const_int 7)
  362.                       (and:SI
  363.                        (match_operand:SI 1 "general_operand" "d")
  364.                        (const_int 7)))))]
  365.   ""
  366.   "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
  367.  
  368. (define_insn ""
  369.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d")
  370.                 (const_int 1)
  371.                 (minus:SI (const_int 31)
  372.                       (and:SI
  373.                        (match_operand:SI 1 "general_operand" "d")
  374.                        (const_int 31)))))]
  375.   ""
  376.   "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
  377.  
  378. ;; Nonoffsettable mem refs are ok in this one pattern
  379. ;; since we don't try to adjust them.
  380. (define_insn ""
  381.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "md")
  382.                 (const_int 1)
  383.                 (match_operand:SI 1 "general_operand" "i")))]
  384.   "GET_CODE (operands[1]) == CONST_INT"
  385.   "*
  386. {
  387.   operands[1] = gen_rtx (CONST_INT, VOIDmode, 7 - INTVAL (operands[1]));
  388.   return output_btst (operands, operands[1], operands[0], insn, 7);
  389. }")
  390.  
  391. (define_insn ""
  392.   ;; The constraint "o,d" here means that a nonoffsettable memref
  393.   ;; will match the first alternative, and its address will be reloaded.
  394.   ;; Copying the memory contents into a reg would be incorrect if the
  395.   ;; bit position is over 7.
  396.   [(set (cc0) (zero_extract (match_operand:HI 0 "nonimmediate_operand" "o,d")
  397.                 (const_int 1)
  398.                 (match_operand:SI 1 "general_operand" "i,i")))]
  399.   "GET_CODE (operands[1]) == CONST_INT"
  400.   "*
  401. {
  402.   if (GET_CODE (operands[0]) == MEM)
  403.     {
  404.       operands[0] = adj_offsettable_operand (operands[0],
  405.                         INTVAL (operands[1]) / 8);
  406.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 
  407.                  7 - INTVAL (operands[1]) % 8);
  408.       return output_btst (operands, operands[1], operands[0], insn, 7);
  409.     }
  410.   operands[1] = gen_rtx (CONST_INT, VOIDmode,
  411.              15 - INTVAL (operands[1]));
  412.   return output_btst (operands, operands[1], operands[0], insn, 15);
  413. }")
  414.  
  415. (define_insn ""
  416.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "do")
  417.                 (const_int 1)
  418.                 (match_operand:SI 1 "general_operand" "i")))]
  419.   "GET_CODE (operands[1]) == CONST_INT"
  420.   "*
  421. {
  422.   if (GET_CODE (operands[0]) == MEM)
  423.     {
  424.       operands[0] = adj_offsettable_operand (operands[0],
  425.                         INTVAL (operands[1]) / 8);
  426.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 
  427.                  7 - INTVAL (operands[1]) % 8);
  428.       return output_btst (operands, operands[1], operands[0], insn, 7);
  429.     }
  430.   operands[1] = gen_rtx (CONST_INT, VOIDmode,
  431.              31 - INTVAL (operands[1]));
  432.   return output_btst (operands, operands[1], operands[0], insn, 31);
  433. }")
  434.  
  435. (define_insn ""
  436.   [(set (cc0)
  437.     (subreg:SI (lshiftrt:QI
  438.             (match_operand:QI 0 "nonimmediate_operand" "dm")
  439.             (const_int 7))
  440.            0))]
  441.   ""
  442.   "*
  443. {
  444.   cc_status.flags = CC_Z_IN_NOT_N | CC_NOT_NEGATIVE;
  445.   return \"tst%.b %0\";
  446. }")
  447.  
  448. (define_insn ""
  449.   [(set (cc0)
  450.     (and:SI (sign_extend:SI
  451.          (sign_extend:HI
  452.           (match_operand:QI 0 "nonimmediate_operand" "dm")))
  453.         (match_operand:SI 1 "general_operand" "i")))]
  454.   "(GET_CODE (operands[1]) == CONST_INT
  455.     && (unsigned) INTVAL (operands[1]) < 0x100
  456.     && exact_log2 (INTVAL (operands[1])) >= 0)"
  457.   "*
  458. { register int log = exact_log2 (INTVAL (operands[1]));
  459.   operands[1] = gen_rtx (CONST_INT, VOIDmode, log);
  460.   return output_btst (operands, operands[1], operands[0], insn, 7);
  461. }")
  462.  
  463. ;; move instructions
  464.  
  465. ;; A special case in which it is not desirable
  466. ;; to reload the constant into a data register.
  467. (define_insn ""
  468.   [(set (match_operand:SI 0 "push_operand" "=m")
  469.     (match_operand:SI 1 "general_operand" "J"))]
  470.   "GET_CODE (operands[1]) == CONST_INT
  471.    && INTVAL (operands[1]) >= -0x8000
  472.    && INTVAL (operands[1]) < 0x8000"
  473.   "*
  474. {
  475.   if (operands[1] == const0_rtx)
  476.     return \"clr%.l %0\";
  477.   return \"pea %a1\";
  478. }")
  479.  
  480. ;This is never used.
  481. ;(define_insn "swapsi"
  482. ;  [(set (match_operand:SI 0 "general_operand" "r")
  483. ;    (match_operand:SI 1 "general_operand" "r"))
  484. ;   (set (match_dup 1) (match_dup 0))]
  485. ;  ""
  486. ;  "exg %1,%0")
  487.  
  488. ;; Special case of fullword move when source is zero.
  489. ;; The reason this is special is to avoid loading a zero
  490. ;; into a data reg with moveq in order to store it elsewhere.
  491.    
  492. (define_insn ""
  493.   [(set (match_operand:SI 0 "general_operand" "=g")
  494.     (const_int 0))]
  495.   ""
  496.   "*
  497. {
  498.   if (ADDRESS_REG_P (operands[0]))
  499.     return \"sub%.l %0,%0\";
  500.   return \"clr%.l %0\";
  501. }")
  502.  
  503. ;; General case of fullword move.  The register constraints
  504. ;; force integer constants in range for a moveq to be reloaded
  505. ;; if they are headed for memory.
  506. (define_insn "movsi"
  507.   ;; Notes: make sure no alternative allows g vs g.
  508.   ;; We don't allow f-regs since fixed point cannot go in them.
  509.   [(set (match_operand:SI 0 "general_operand" "=dam")
  510.     (match_operand:SI 1 "general_operand" "dami"))]
  511.   ""
  512.   "*
  513. {
  514.   if (GET_CODE (operands[1]) == CONST_INT)
  515.     {
  516.       if (operands[1] == const0_rtx
  517.       && (DATA_REG_P (operands[0])
  518.           || GET_CODE (operands[0]) == MEM))
  519.     return \"clr%.l %0\";
  520.       else if (DATA_REG_P (operands[0])
  521.            && INTVAL (operands[1]) < 128
  522.            && INTVAL (operands[1]) >= -128)
  523.         {
  524.           return \"moveq%.l %1,%0\";
  525.     }
  526.       else if (ADDRESS_REG_P (operands[0])
  527.            && INTVAL (operands[1]) < 0x8000
  528.            && INTVAL (operands[1]) >= -0x8000)
  529.     return \"move%.w %1,%0\";
  530.       else if (push_operand (operands[0], SImode)
  531.            && INTVAL (operands[1]) < 0x8000
  532.            && INTVAL (operands[1]) >= -0x8000)
  533.         return \"pea %a1\";
  534.     }
  535.   else if ((GET_CODE (operands[1]) == SYMBOL_REF
  536.         || GET_CODE (operands[1]) == CONST)
  537.        && push_operand (operands[0], SImode))
  538.     return \"pea %a1\";
  539.   else if ((GET_CODE (operands[1]) == SYMBOL_REF
  540.         || GET_CODE (operands[1]) == CONST)) {
  541.            if (ADDRESS_REG_P (operands[0])) {
  542.                return \"lea %a1,%0\";
  543.            } else {
  544.                return \"pea %a1\;move%.l %+,%0\";
  545.            }
  546.   }
  547.   return \"move%.l %1,%0\";
  548. }")
  549.  
  550. (define_insn "movhi"
  551.   [(set (match_operand:HI 0 "general_operand" "=g")
  552.     (match_operand:HI 1 "general_operand" "g"))]
  553.   ""
  554.   "*
  555. {
  556.   if (GET_CODE (operands[1]) == CONST_INT)
  557.     {
  558.       if (operands[1] == const0_rtx
  559.       && (DATA_REG_P (operands[0])
  560.           || GET_CODE (operands[0]) == MEM))
  561.     return \"clr%.w %0\";
  562.       else if (DATA_REG_P (operands[0])
  563.            && INTVAL (operands[1]) < 128
  564.            && INTVAL (operands[1]) >= -128)
  565.         {
  566.           return \"moveq%.l %1,%0\";
  567.     }
  568.       else if (INTVAL (operands[1]) < 0x8000
  569.            && INTVAL (operands[1]) >= -0x8000)
  570.     return \"move%.w %1,%0\";
  571.     }
  572.   else if (CONSTANT_P (operands[1]))
  573.     return \"move%.l %1,%0\";
  574.   return \"move%.w %1,%0\";
  575. }")
  576.  
  577. (define_insn "movstricthi"
  578.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  579.     (match_operand:HI 1 "general_operand" "rmn"))]
  580.   ""
  581.   "*
  582. {
  583.   if (GET_CODE (operands[1]) == CONST_INT)
  584.     {
  585.       if (operands[1] == const0_rtx
  586.       && (DATA_REG_P (operands[0])
  587.           || GET_CODE (operands[0]) == MEM))
  588.     return \"clr%.w %0\";
  589.     }
  590.   return \"move%.w %1,%0\";
  591. }")
  592.  
  593. (define_insn "movqi"
  594.   [(set (match_operand:QI 0 "general_operand" "=d,*a,m")
  595.     (match_operand:QI 1 "general_operand" "dmi*a,d*a,dmi"))]
  596.   ""
  597.   "*
  598. {
  599.   if (operands[1] == const0_rtx)
  600.     return \"clr%.b %0\";
  601.   if (GET_CODE (operands[1]) == CONST_INT
  602.       && INTVAL (operands[1]) == -1)
  603.     return \"st %0\";
  604.   if (GET_CODE (operands[1]) != CONST_INT && CONSTANT_P (operands[1]))
  605.     return \"move%.l %1,%0\";
  606.   if (ADDRESS_REG_P (operands[0]) || ADDRESS_REG_P (operands[1]))
  607.     return \"move%.w %1,%0\";
  608.   return \"move%.b %1,%0\";
  609. }")
  610.  
  611. (define_insn "movstrictqi"
  612.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  613.     (match_operand:QI 1 "general_operand" "dmn"))]
  614.   ""
  615.   "*
  616. {
  617.   if (operands[1] == const0_rtx)
  618.     return \"clr%.b %0\";
  619.   return \"move%.b %1,%0\";
  620. }")
  621.  
  622. (define_insn "movsf"
  623.   [(set (match_operand:SF 0 "general_operand" "=rmf")
  624.     (match_operand:SF 1 "general_operand" "rmfF"))]
  625.   ""
  626.   "*
  627. {
  628.   if (FP_REG_P (operands[0]))
  629.     {
  630.       if (FP_REG_P (operands[1]))
  631.     return \"fmove%.x %1,%0\";
  632.       else if (ADDRESS_REG_P (operands[1]))
  633.     return \"move%.l %1,%-\;fmove%.s %+,%0\";
  634.       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
  635.     return output_move_const_single (operands);
  636.       return \"fmove%.s %1,%0\";
  637.     }
  638.   if (FP_REG_P (operands[1]))
  639.     {
  640.       if (ADDRESS_REG_P (operands[0]))
  641.     return \"fmove%.s %1,%-\;move%.l %+,%0\";
  642.       return \"fmove%.s %1,%0\";
  643.     }
  644.   return \"move%.l %f1,%0\";
  645. }")
  646.  
  647. (define_insn "movdf"
  648.   [(set (match_operand:DF 0 "general_operand" "=rm,&rf,&ro<>f")
  649.     (match_operand:DF 1 "general_operand" "rf,m,ro<>fF"))]
  650.   ""
  651.   "*
  652. {
  653.   if (FP_REG_P (operands[0]))
  654.     {
  655.       if (FP_REG_P (operands[1]))
  656.     return \"fmove%.x %1,%0\";
  657.       if (REG_P (operands[1]))
  658.     {
  659.       rtx xoperands[2];
  660.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  661.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  662.       output_asm_insn (\"move%.l %1,%-\", operands);
  663.       return \"fmove%.d %+,%0\";
  664.     }
  665.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  666.     return output_move_const_double (operands);
  667.       return \"fmove%.d %1,%0\";
  668.     }
  669.   else if (FP_REG_P (operands[1]))
  670.     {
  671.       if (REG_P (operands[0]))
  672.     {
  673.       output_asm_insn (\"fmove%.d %1,%-\;move%.l %+,%0\", operands);
  674.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  675.       return \"move%.l %+,%0\";
  676.     }
  677.       else
  678.         return \"fmove%.d %1,%0\";
  679.     }
  680.   return output_move_double (operands);
  681. }
  682. ")
  683.  
  684. ;; In the following defn, note that FP regs occur iff nums are 96 bits.
  685.  
  686. (define_insn "movxf"
  687.   [(set (match_operand:XF 0 "general_operand" "=&ro<>f")
  688.     (match_operand:XF 1 "general_operand" "ro<>fF"))]
  689.   ""
  690.   "*
  691. {
  692.   if (FP_REG_P (operands[0]))
  693.     {
  694.       if (FP_REG_P (operands[1]))
  695.     return \"fmove%.x %1,%0\";
  696.       if (REG_P (operands[1]))
  697.     {
  698.       rtx xoperands[2], xxoperands[2];
  699.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  700.       xxoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2);
  701.       output_asm_insn (\"move%.l %1,%-\", xxoperands);
  702.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  703.       output_asm_insn (\"move%.l %1,%-\", operands);
  704.       return \"fmove%.x %+,%0\";
  705.     }
  706.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  707.     return output_move_const_long_double (operands);
  708.       return \"fmove%.x %1,%0\";
  709.     }
  710.   else if (FP_REG_P (operands[1]))
  711.     {
  712.       if (REG_P (operands[0]))
  713.     {
  714.       output_asm_insn (\"fmove%.x %1,%-\;move%.l %+,%0\", operands);
  715.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  716.       output_asm_insn (\"move%.l %+,%0\", operands);
  717.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  718.       return \"move%.l %+,%0\";
  719.     }
  720.       else
  721.         return \"fmove%.x %1,%0\";
  722.     }
  723.   return output_move_extended (operands);
  724. }
  725. ")
  726.  
  727. ;; movdi can apply to fp regs in some cases
  728. (define_insn "movdi"
  729.   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
  730.   [(set (match_operand:DI 0 "general_operand" "=rm,&rf,&ro<>,!&rm,!&f")
  731.     (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
  732.   ""
  733.   "*
  734. {
  735.   if (FP_REG_P (operands[0]))
  736.     {
  737.       if (FP_REG_P (operands[1]))
  738.     return \"fmove%.x %1,%0\";
  739.       if (REG_P (operands[1]))
  740.     {
  741.       rtx xoperands[2];
  742.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  743.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  744.       output_asm_insn (\"move%.l %1,%-\", operands);
  745.       return \"fmove%.d %+,%0\";
  746.     }
  747.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  748.     return output_move_const_double (operands);
  749.       return \"fmove%.d %1,%0\";
  750.     }
  751.   else if (FP_REG_P (operands[1]))
  752.     {
  753.       if (REG_P (operands[0]))
  754.     {
  755.       output_asm_insn (\"fmove%.d %1,%-\;move%.l %+,%0\", operands);
  756.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  757.       return \"move%.l %+,%0\";
  758.     }
  759.       else
  760.         return \"fmove%.d %1,%0\";
  761.     }
  762.   return output_move_double (operands);
  763. }
  764. ")
  765.  
  766. ;; Thus goes after the move instructions
  767. ;; because the move instructions are better (require no spilling)
  768. ;; when they can apply.  It goes before the add/sub insns
  769. ;; so we will prefer it to them.
  770.  
  771. (define_insn "pushasi"
  772.   [(set (match_operand:SI 0 "push_operand" "=m")
  773.     (match_operand:SI 1 "address_operand" "p"))]
  774.   ""
  775.   "pea %a1")
  776.  
  777. ;; truncation instructions
  778. (define_insn "truncsiqi2"
  779.   [(set (match_operand:QI 0 "general_operand" "=dm,d")
  780.     (truncate:QI
  781.      (match_operand:SI 1 "general_operand" "doJ,i")))]
  782.   ""
  783.   "*
  784. {
  785.   if (GET_CODE (operands[0]) == REG)
  786.     return \"move%.l %1,%0\";
  787.   if (GET_CODE (operands[1]) == MEM)
  788.     operands[1] = adj_offsettable_operand (operands[1], 3);
  789.   return \"move%.b %1,%0\";
  790. }")
  791.  
  792. (define_insn "trunchiqi2"
  793.   [(set (match_operand:QI 0 "general_operand" "=dm,d")
  794.     (truncate:QI
  795.      (match_operand:HI 1 "general_operand" "doJ,i")))]
  796.   ""
  797.   "*
  798. {
  799.   if (GET_CODE (operands[0]) == REG)
  800.     return \"move%.l %1,%0\";
  801.   if (GET_CODE (operands[1]) == MEM)
  802.     operands[1] = adj_offsettable_operand (operands[1], 1);
  803.   return \"move%.b %1,%0\";
  804. }")
  805.  
  806. (define_insn "truncsihi2"
  807.   [(set (match_operand:HI 0 "general_operand" "=dm,d")
  808.     (truncate:HI
  809.      (match_operand:SI 1 "general_operand" "roJ,i")))]
  810.   ""
  811.   "*
  812. {
  813.   if (GET_CODE (operands[0]) == REG)
  814.     return \"move%.l %1,%0\";
  815.   if (GET_CODE (operands[1]) == MEM)
  816.     operands[1] = adj_offsettable_operand (operands[1], 2);
  817.   return \"move%.w %1,%0\";
  818. }")
  819.  
  820. ;; zero extension instructions
  821.  
  822. (define_expand "zero_extendhisi2"
  823.   [(set (match_operand:SI 0 "register_operand" "")
  824.     (const_int 0))
  825.    (set (strict_low_part (subreg:HI (match_dup 0) 0))
  826.     (match_operand:HI 1 "general_operand" ""))]
  827.   ""
  828.   "operands[1] = make_safe_from (operands[1], operands[0]);")
  829.  
  830. (define_expand "zero_extendqihi2"
  831.   [(set (match_operand:HI 0 "register_operand" "")
  832.     (const_int 0))
  833.    (set (strict_low_part (subreg:QI (match_dup 0) 0))
  834.     (match_operand:QI 1 "general_operand" ""))]
  835.   ""
  836.   "operands[1] = make_safe_from (operands[1], operands[0]);")
  837.  
  838. (define_expand "zero_extendqisi2"
  839.   [(set (match_operand:SI 0 "register_operand" "")
  840.     (const_int 0))
  841.    (set (strict_low_part (subreg:QI (match_dup 0) 0))
  842.     (match_operand:QI 1 "general_operand" ""))]
  843.   ""
  844.   " operands[1] = make_safe_from (operands[1], operands[0]); ")
  845.  
  846. ;; Patterns to recognize zero-extend insns produced by the combiner.
  847.  
  848. ;; Note that the one starting from HImode comes before those for QImode
  849. ;; so that a constant operand will match HImode, not QImode.
  850. (define_insn ""
  851.   [(set (match_operand:SI 0 "general_operand" "=do<>")
  852.     (zero_extend:SI
  853.      (match_operand:HI 1 "general_operand" "rmn")))]
  854.   ""
  855.   "*
  856. {
  857.   if (DATA_REG_P (operands[0]))
  858.     {
  859.       if (GET_CODE (operands[1]) == REG
  860.       && REGNO (operands[0]) == REGNO (operands[1]))
  861.     return \"and%.l #$FFFF,%0\";
  862.       if (reg_mentioned_p (operands[0], operands[1]))
  863.         return \"move%.w %1,%0\;and%.l #$FFFF,%0\";
  864.       return \"clr%.l %0\;move%.w %1,%0\";
  865.     }
  866.   else if (GET_CODE (operands[0]) == MEM
  867.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  868.     return \"move%.w %1,%0\;clr%.w %0\";
  869.   else if (GET_CODE (operands[0]) == MEM
  870.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  871.     return \"clr%.w %0\;move%.w %1,%0\";
  872.   else
  873.     {
  874.       output_asm_insn (\"clr%.w %0\", operands);
  875.       operands[0] = adj_offsettable_operand (operands[0], 2);
  876.       return \"move%.w %1,%0\";
  877.     }
  878. }")
  879.  
  880. (define_insn ""
  881.   [(set (match_operand:HI 0 "general_operand" "=do<>")
  882.     (zero_extend:HI
  883.      (match_operand:QI 1 "general_operand" "dmn")))]
  884.   ""
  885.   "*
  886. {
  887.   if (DATA_REG_P (operands[0]))
  888.     {
  889.       if (GET_CODE (operands[1]) == REG
  890.       && REGNO (operands[0]) == REGNO (operands[1]))
  891.     return \"and%.w #$FF,%0\";
  892.       if (reg_mentioned_p (operands[0], operands[1]))
  893.         return \"move%.b %1,%0\;and%.w #$FF,%0\";
  894.       return \"clr%.w %0\;move%.b %1,%0\";
  895.     }
  896.   else if (GET_CODE (operands[0]) == MEM
  897.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  898.     {
  899.       if (REGNO (XEXP (XEXP (operands[0], 0), 0))
  900.       == STACK_POINTER_REGNUM)
  901.     return \"clr%.w %-\;move%.b %1,%0\";
  902.       else
  903.     return \"move%.b %1,%0\;clr%.b %0\";
  904.     }
  905.   else if (GET_CODE (operands[0]) == MEM
  906.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  907.     return \"clr%.b %0\;move%.b %1,%0\";
  908.   else
  909.     {
  910.       output_asm_insn (\"clr%.b %0\", operands);
  911.       operands[0] = adj_offsettable_operand (operands[0], 1);
  912.       return \"move%.b %1,%0\";
  913.     }
  914. }")
  915.  
  916. (define_insn ""
  917.   [(set (match_operand:SI 0 "general_operand" "=do<>")
  918.     (zero_extend:SI
  919.      (match_operand:QI 1 "general_operand" "dmn")))]
  920.   ""
  921.   "*
  922. {
  923.   if (DATA_REG_P (operands[0]))
  924.     {
  925.       if (GET_CODE (operands[1]) == REG
  926.       && REGNO (operands[0]) == REGNO (operands[1]))
  927.     return \"and%.l #$FF,%0\";
  928.       if (reg_mentioned_p (operands[0], operands[1]))
  929.         return \"move%.b %1,%0\;and%.l #$FF,%0\";
  930.       return \"clr%.l %0\;move%.b %1,%0\";
  931.     }
  932.   else if (GET_CODE (operands[0]) == MEM
  933.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  934.     {
  935.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  936.       return \"clr%.l -(%0)\;move%.b %1,(3,%0)\";
  937.     }
  938.   else if (GET_CODE (operands[0]) == MEM
  939.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  940.     {
  941.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  942.       return \"clr%.l (%0)+\;move%.b %1,(-1,%0)\";
  943.     }
  944.   else
  945.     {
  946.       output_asm_insn (\"clr%.l %0\", operands);
  947.       operands[0] = adj_offsettable_operand (operands[0], 3);
  948.       return \"move%.b %1,%0\";
  949.     }
  950. }")
  951.  
  952. ;; sign extension instructions
  953. ;; Note that the one starting from HImode comes before those for QImode
  954. ;; so that a constant operand will match HImode, not QImode.
  955.  
  956. (define_insn "extendhisi2"
  957.   [(set (match_operand:SI 0 "general_operand" "=*d,a")
  958.     (sign_extend:SI
  959.      (match_operand:HI 1 "general_operand" "0,rmn")))]
  960.   ""
  961.   "*
  962. {
  963.   if (ADDRESS_REG_P (operands[0]))
  964.     return \"move%.w %1,%0\";
  965.   return \"ext%.l %0\";
  966. }")
  967.  
  968. (define_insn "extendqihi2"
  969.   [(set (match_operand:HI 0 "general_operand" "=d")
  970.     (sign_extend:HI
  971.      (match_operand:QI 1 "general_operand" "0")))]
  972.   ""
  973.   "ext%.w %0")
  974.  
  975. (define_insn "extendqisi2"
  976.   [(set (match_operand:SI 0 "general_operand" "=d")
  977.     (sign_extend:SI
  978.      (match_operand:QI 1 "general_operand" "0")))]
  979.   "TARGET_68020"
  980.   "extb%.l %0")
  981.  
  982. ;; Conversions between float, double, and long double.
  983.  
  984. (define_expand "extendsfdf2"
  985.   [(set (match_operand:DF 0 "general_operand" "")
  986.     (float_extend:DF
  987.       (match_operand:SF 1 "general_operand" "")))]
  988.   "TARGET_SANE || TARGET_68881"
  989.   "")
  990.  
  991. (define_insn ""
  992.   [(set (match_operand:DF 0 "general_operand" "=*fdm,f")
  993.     (float_extend:DF
  994.       (match_operand:SF 1 "general_operand" "f,dmF")))]
  995.   "TARGET_68881"
  996.   "*
  997. {
  998.   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
  999.     {
  1000.       if (REGNO (operands[0]) == REGNO (operands[1]))
  1001.     {
  1002.       /* Extending float to double in an fp-reg is a no-op.
  1003.          NOTICE_UPDATE_CC has already assumed that the
  1004.          cc will be set.  So cancel what it did.  */
  1005.       cc_status = cc_prev_status;
  1006.       return \"\";
  1007.     }
  1008.       return \"fmove%.x %1,%0\";
  1009.     }
  1010.   if (FP_REG_P (operands[0]))
  1011.     return \"fmove%.s %1,%0\";
  1012.   if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
  1013.     {
  1014.       output_asm_insn (\"fmove%.d %1,%-\;move%.l %+,%0\", operands);
  1015.       /* seems unreliable - what if opnd 0 was d7? */
  1016.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1017.       return \"move%.l %+,%0\";
  1018.     }
  1019.   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1]))
  1020.     return \"fmove%.d %1,%0\";
  1021. }")
  1022.  
  1023. (define_insn ""
  1024.   [(set (match_operand:DF 0 "general_operand" "=ro")
  1025.     (float_extend:DF
  1026.       (match_operand:SF 1 "general_operand" "ro")))]
  1027.   "TARGET_SANE"
  1028.   "* return output_sane_convert(operands);")
  1029.  
  1030. (define_expand "extendsfxf2"
  1031.   [(set (match_operand:XF 0 "general_operand" "")
  1032.     (float_extend:XF
  1033.       (match_operand:SF 1 "general_operand" "")))]
  1034.   "TARGET_SANE || TARGET_68881"
  1035.   "")
  1036.  
  1037. (define_insn ""
  1038.   [(set (match_operand:XF 0 "general_operand" "=*fm,f")
  1039.     (float_extend:XF
  1040.       (match_operand:SF 1 "general_operand" "f,dmF")))]
  1041.   "TARGET_68881"
  1042.   "*
  1043. {
  1044.   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
  1045.     {
  1046.       if (REGNO (operands[0]) == REGNO (operands[1]))
  1047.     {
  1048.       /* Extending float to long double in an fp-reg is a no-op.
  1049.          NOTICE_UPDATE_CC has already assumed that the
  1050.          cc will be set.  So cancel what it did.  */
  1051.       cc_status = cc_prev_status;
  1052.       return \"\";
  1053.     }
  1054.       return \"fmove%.x %1,%0\";
  1055.     }
  1056.   if (FP_REG_P (operands[0]))
  1057.     return \"fmove%.s %1,%0\";
  1058.   return \"fmove%.x %1,%0\";
  1059. }")
  1060.  
  1061. (define_insn ""
  1062.   [(set (match_operand:XF 0 "general_operand" "=ro")
  1063.     (float_extend:XF
  1064.       (match_operand:SF 1 "general_operand" "ro")))]
  1065.   "TARGET_SANE"
  1066.   "* return output_sane_convert(operands);")
  1067.  
  1068. (define_expand "extenddfxf2"
  1069.   [(set (match_operand:XF 0 "general_operand" "")
  1070.     (float_extend:XF
  1071.       (match_operand:DF 1 "general_operand" "")))]
  1072.   "TARGET_SANE || TARGET_68881"
  1073.   "")
  1074.  
  1075. (define_insn ""
  1076.   [(set (match_operand:XF 0 "general_operand" "=*fm,f")
  1077.     (float_extend:XF
  1078.       (match_operand:DF 1 "general_operand" "f,mF")))]
  1079.   "TARGET_68881"
  1080.   "*
  1081. {
  1082.   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
  1083.     {
  1084.       if (REGNO (operands[0]) == REGNO (operands[1]))
  1085.     {
  1086.       /* Extending double to long double in an fp-reg is a no-op.
  1087.          NOTICE_UPDATE_CC has already assumed that the
  1088.          cc will be set.  So cancel what it did.  */
  1089.       cc_status = cc_prev_status;
  1090.       return \"\";
  1091.     }
  1092.       return \"fmove%.x %1,%0\";
  1093.     }
  1094.   if (FP_REG_P (operands[0]))
  1095.     return \"fmove%.d %1,%0\";
  1096.   return \"fmove%.x %1,%0\";
  1097. }")
  1098.  
  1099. (define_insn ""
  1100.   [(set (match_operand:XF 0 "general_operand" "=ro")
  1101.     (float_extend:XF
  1102.       (match_operand:DF 1 "general_operand" "ro")))]
  1103.   "TARGET_SANE"
  1104.   "* return output_sane_convert (operands);")
  1105.  
  1106. ;; Truncation of floats.
  1107.  
  1108. (define_expand "truncdfsf2"
  1109.   [(set (match_operand:SF 0 "general_operand" "")
  1110.     (float_truncate:SF
  1111.       (match_operand:DF 1 "general_operand" "")))]
  1112.   "TARGET_SANE || TARGET_68881"
  1113.   "")
  1114.  
  1115. ;; This cannot output into an f-reg because there is no way to be
  1116. ;; sure of truncating in that case.
  1117.  
  1118. (define_insn ""
  1119.   [(set (match_operand:SF 0 "general_operand" "=dm")
  1120.     (float_truncate:SF
  1121.       (match_operand:DF 1 "general_operand" "f")))]
  1122.   "TARGET_68881"
  1123.   "fmove%.s %1,%0")
  1124.  
  1125. (define_insn ""
  1126.   [(set (match_operand:SF 0 "general_operand" "=ro")
  1127.     (float_truncate:SF
  1128.       (match_operand:DF 1 "general_operand" "ro")))]
  1129.   "TARGET_SANE"
  1130.   "* return output_sane_convert (operands);")
  1131.  
  1132. (define_expand "truncxfsf2"
  1133.   [(set (match_operand:SF 0 "general_operand" "")
  1134.     (float_truncate:SF
  1135.       (match_operand:XF 1 "general_operand" "")))]
  1136.   "TARGET_SANE || TARGET_68881"
  1137.   "")
  1138.  
  1139. (define_insn ""
  1140.   [(set (match_operand:SF 0 "general_operand" "=dm")
  1141.     (float_truncate:SF
  1142.       (match_operand:XF 1 "general_operand" "f")))]
  1143.   "TARGET_68881"
  1144.   "fmove%.s %1,%0")
  1145.  
  1146. (define_insn ""
  1147.   [(set (match_operand:SF 0 "general_operand" "=ro")
  1148.     (float_truncate:SF
  1149.       (match_operand:XF 1 "general_operand" "ro")))]
  1150.   "TARGET_SANE"
  1151.   "* return output_sane_convert (operands);")
  1152.  
  1153. (define_expand "truncxfdf2"
  1154.   [(set (match_operand:DF 0 "general_operand" "")
  1155.     (float_truncate:DF
  1156.       (match_operand:XF 1 "general_operand" "")))]
  1157.   "TARGET_SANE || TARGET_68881"
  1158.   "")
  1159.  
  1160. ;; This cannot output into an f-reg because there is no way to be
  1161. ;; sure of truncating in that case.
  1162.  
  1163. (define_insn ""
  1164.   [(set (match_operand:DF 0 "general_operand" "=dm")
  1165.     (float_truncate:DF
  1166.       (match_operand:XF 1 "general_operand" "f")))]
  1167.   "TARGET_68881"
  1168.   "*
  1169. {
  1170.   if (DATA_REG_P (operands[0]))
  1171.     {
  1172.       output_asm_insn (\"fmove%.d %1,%-\;move%.l %+,%0\", operands);
  1173.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1174.       return \"move%.l %+,%0\";
  1175.     }
  1176.   return \"fmove%.d %1,%0\";
  1177. }")
  1178.  
  1179. (define_insn ""
  1180.   [(set (match_operand:DF 0 "general_operand" "=ro")
  1181.     (float_truncate:DF
  1182.       (match_operand:XF 1 "general_operand" "ro")))]
  1183.   "TARGET_SANE"
  1184.   "* return output_sane_convert (operands);")
  1185.  
  1186. ;; Conversion between fixed point and floating point.
  1187. ;; Note that among the fix-to-float insns
  1188. ;; the ones that start with SImode come first.
  1189. ;; That is so that an operand that is a CONST_INT
  1190. ;; (and therefore lacks a specific machine mode).
  1191. ;; will be recognized as SImode (which is always valid)
  1192. ;; rather than as QImode or HImode.
  1193.  
  1194. (define_expand "floatsisf2"
  1195.   [(set (match_operand:SF 0 "general_operand" "")
  1196.     (float:SF (match_operand:SI 1 "general_operand" "")))]
  1197.   "TARGET_SANE || TARGET_68881"
  1198.   "")
  1199.  
  1200. (define_insn ""
  1201.   [(set (match_operand:SF 0 "general_operand" "=f")
  1202.     (float:SF (match_operand:SI 1 "general_operand" "dmi")))]
  1203.   "TARGET_68881"
  1204.   "fmove%.l %1,%0")
  1205.  
  1206. (define_insn ""
  1207.   [(set (match_operand:SF 0 "general_operand" "=ro")
  1208.     (float:SF (match_operand:SI 1 "general_operand" "ro")))]
  1209.   "TARGET_SANE"
  1210.   "* return output_sane_convert (operands);")
  1211.  
  1212. (define_expand "floatsidf2"
  1213.   [(set (match_operand:DF 0 "general_operand" "")
  1214.     (float:DF (match_operand:SI 1 "general_operand" "")))]
  1215.   "TARGET_SANE || TARGET_68881"
  1216.   "")
  1217.  
  1218. (define_insn ""
  1219.   [(set (match_operand:DF 0 "general_operand" "=f")
  1220.     (float:DF (match_operand:SI 1 "general_operand" "dmi")))]
  1221.   "TARGET_68881"
  1222.   "fmove%.l %1,%0")
  1223.  
  1224. (define_insn ""
  1225.   [(set (match_operand:DF 0 "general_operand" "=ro")
  1226.     (float:DF (match_operand:SI 1 "general_operand" "ro")))]
  1227.   "TARGET_SANE"
  1228.   "* return output_sane_convert (operands);")
  1229.  
  1230. (define_expand "floatsixf2"
  1231.   [(set (match_operand:XF 0 "general_operand" "")
  1232.     (float:XF (match_operand:SI 1 "general_operand" "")))]
  1233.   "TARGET_SANE || TARGET_68881"
  1234.   "")
  1235.  
  1236. (define_insn ""
  1237.   [(set (match_operand:XF 0 "general_operand" "=f")
  1238.     (float:XF (match_operand:SI 1 "general_operand" "dmi")))]
  1239.   "TARGET_68881"
  1240.   "fmove%.l %1,%0")
  1241.  
  1242. (define_insn ""
  1243.   [(set (match_operand:XF 0 "general_operand" "=ro")
  1244.     (float:XF (match_operand:SI 1 "general_operand" "ro")))]
  1245.   "TARGET_SANE"
  1246.   "* return output_sane_convert (operands);")
  1247.  
  1248. (define_insn "floathisf2"
  1249.   [(set (match_operand:SF 0 "general_operand" "=f")
  1250.     (float:SF (match_operand:HI 1 "general_operand" "dmn")))]
  1251.   "TARGET_68881"
  1252.   "fmove%.w %1,%0")
  1253.  
  1254. (define_insn "floathidf2"
  1255.   [(set (match_operand:DF 0 "general_operand" "=f")
  1256.     (float:DF (match_operand:HI 1 "general_operand" "dmn")))]
  1257.   "TARGET_68881"
  1258.   "fmove%.w %1,%0")
  1259.  
  1260. (define_insn "floathixf2"
  1261.   [(set (match_operand:XF 0 "general_operand" "=f")
  1262.     (float:XF (match_operand:HI 1 "general_operand" "dmn")))]
  1263.   "TARGET_68881"
  1264.   "fmove%.w %1,%0")
  1265.  
  1266. (define_insn "floatqisf2"
  1267.   [(set (match_operand:SF 0 "general_operand" "=f")
  1268.     (float:SF (match_operand:QI 1 "general_operand" "dmn")))]
  1269.   "TARGET_68881"
  1270.   "fmove%.b %1,%0")
  1271.  
  1272. (define_insn "floatqidf2"
  1273.   [(set (match_operand:DF 0 "general_operand" "=f")
  1274.     (float:DF (match_operand:QI 1 "general_operand" "dmn")))]
  1275.   "TARGET_68881"
  1276.   "fmove%.b %1,%0")
  1277.  
  1278. (define_insn "floatqixf2"
  1279.   [(set (match_operand:XF 0 "general_operand" "=f")
  1280.     (float:XF (match_operand:QI 1 "general_operand" "dmn")))]
  1281.   "TARGET_68881"
  1282.   "fmove%.b %1,%0")
  1283.  
  1284. ;; Convert a float to a float whose value is an integer.
  1285. ;; This is the first stage of converting it to an integer type.
  1286.  
  1287. (define_expand "ftruncsf2"
  1288.   [(set (match_operand:SF 0 "general_operand" "")
  1289.     (fix:SF (match_operand:SF 1 "general_operand" "")))]
  1290.   "TARGET_SANE || TARGET_68881"
  1291.   "")
  1292.  
  1293. (define_insn ""
  1294.   [(set (match_operand:SF 0 "general_operand" "=ro")
  1295.     (fix:SF (match_operand:SF 1 "general_operand" "0")))]
  1296.   "TARGET_SANE"
  1297.   "* return output_sane_2 (operands, 0x0016, \"FTINTX\");")
  1298.  
  1299. (define_insn ""
  1300.   [(set (match_operand:SF 0 "general_operand" "=f")
  1301.     (fix:SF (match_operand:SF 1 "general_operand" "dfmF")))]
  1302.   "TARGET_68881"
  1303.   "*
  1304. {
  1305.   if (FP_REG_P (operands[1]))
  1306.     return \"fintrz%.x %1,%0\";
  1307.   return \"fintrz%.s%1,%0\";
  1308. }")
  1309.  
  1310. (define_expand "ftruncdf2"
  1311.   [(set (match_operand:DF 0 "general_operand" "")
  1312.     (fix:DF (match_operand:DF 1 "general_operand" "")))]
  1313.   "TARGET_SANE || TARGET_68881"
  1314.   "")
  1315.  
  1316. (define_insn ""
  1317.   [(set (match_operand:DF 0 "general_operand" "=ro")
  1318.     (fix:DF (match_operand:DF 1 "general_operand" "0")))]
  1319.   "TARGET_SANE"
  1320.   "* return output_sane_2 (operands, 0x0016, \"FTINTX\");")
  1321.  
  1322. (define_insn ""
  1323.   [(set (match_operand:DF 0 "general_operand" "=f")
  1324.     (fix:DF (match_operand:DF 1 "general_operand" "fmF")))]
  1325.   "TARGET_68881"
  1326.   "*
  1327. {
  1328.   if (FP_REG_P (operands[1]))
  1329.     return \"fintrz%.x %1,%0\";
  1330.   return \"fintrz%.d %1,%0\";
  1331. }")
  1332.  
  1333. (define_expand "ftruncxf2"
  1334.   [(set (match_operand:XF 0 "general_operand" "")
  1335.     (fix:XF (match_operand:XF 1 "general_operand" "")))]
  1336.   "TARGET_SANE || TARGET_68881"
  1337.   "")
  1338.  
  1339. (define_insn ""
  1340.   [(set (match_operand:XF 0 "general_operand" "=ro")
  1341.     (fix:XF (match_operand:XF 1 "general_operand" "0")))]
  1342.   "TARGET_SANE"
  1343.   "* return output_sane_2 (operands, 0x0016, \"FTINTX\");")
  1344.  
  1345. (define_insn ""
  1346.   [(set (match_operand:XF 0 "general_operand" "=f")
  1347.     (fix:XF (match_operand:XF 1 "general_operand" "fmF")))]
  1348.   "TARGET_68881"
  1349.   "fintrz%.x %1,%0")
  1350.  
  1351. ;; Convert a float whose value is an integer
  1352. ;; to an actual integer.  Second stage of converting float to integer type.
  1353.  
  1354. (define_insn "fixsfqi2"
  1355.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1356.     (fix:QI (match_operand:SF 1 "general_operand" "f")))]
  1357.   "TARGET_68881"
  1358.   "fmove%.b %1,%0")
  1359.  
  1360. (define_insn "fixsfhi2"
  1361.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1362.     (fix:HI (match_operand:SF 1 "general_operand" "f")))]
  1363.   "TARGET_68881"
  1364.   "fmove%.w %1,%0")
  1365.  
  1366. (define_insn "fixsfsi2"
  1367.   [(set (match_operand:SI 0 "general_operand" "=dm")
  1368.     (fix:SI (match_operand:SF 1 "general_operand" "f")))]
  1369.   "TARGET_68881"
  1370.   "fmove%.l %1,%0")
  1371.  
  1372. (define_insn "fixdfqi2"
  1373.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1374.     (fix:QI (match_operand:DF 1 "general_operand" "f")))]
  1375.   "TARGET_68881"
  1376.   "fmove%.b %1,%0")
  1377.  
  1378. (define_insn "fixdfhi2"
  1379.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1380.     (fix:HI (match_operand:DF 1 "general_operand" "f")))]
  1381.   "TARGET_68881"
  1382.   "fmove%.w %1,%0")
  1383.  
  1384. (define_insn "fixdfsi2"
  1385.   [(set (match_operand:SI 0 "general_operand" "=dm")
  1386.     (fix:SI (match_operand:DF 1 "general_operand" "f")))]
  1387.   "TARGET_68881"
  1388.   "fmove%.l %1,%0")
  1389.  
  1390. (define_insn "fixxfqi2"
  1391.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1392.     (fix:QI (match_operand:XF 1 "general_operand" "f")))]
  1393.   "TARGET_68881"
  1394.   "fmove%.b %1,%0")
  1395.  
  1396. (define_insn "fixxfhi2"
  1397.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1398.     (fix:HI (match_operand:XF 1 "general_operand" "f")))]
  1399.   "TARGET_68881"
  1400.   "fmove%.w %1,%0")
  1401.  
  1402. (define_expand "fixxfsi2"
  1403.   [(set (match_operand:SI 0 "general_operand" "")
  1404.     (fix:SI (match_operand:XF 1 "general_operand" "")))]
  1405.   "TARGET_SANE || TARGET_68881"
  1406.   "")
  1407.  
  1408. (define_insn ""
  1409.   [(set (match_operand:SI 0 "general_operand" "=do")
  1410.     (fix:SI (match_operand:XF 1 "general_operand" "ro")))]
  1411.   "TARGET_SANE"
  1412.   "* return output_lib_convert(operands, \"_XTOI\");")
  1413.  
  1414. (define_insn ""
  1415.   [(set (match_operand:SI 0 "general_operand" "=dm")
  1416.     (fix:SI (match_operand:XF 1 "general_operand" "f")))]
  1417.   "TARGET_68881"
  1418.   "fmove%.l %1,%0")
  1419.  
  1420. ;(define_expand "fixunsdfsi2"
  1421. ;  [(set (match_operand:SI 0 "general_operand" "")
  1422. ;    (unsigned_fix:SI (match_operand:DF 1 "general_operand" "")))]
  1423. ;  "TARGET_SANE || TARGET_68881"
  1424. ;  "")
  1425.  
  1426. (define_expand "fixunsxfsi2"
  1427.   [(set (match_operand:SI 0 "general_operand" "")
  1428.     (unsigned_fix:SI (match_operand:XF 1 "general_operand" "")))]
  1429.   "TARGET_SANE || TARGET_68881"
  1430.   "")
  1431.  
  1432. (define_insn ""
  1433.   [(set (match_operand:SI 0 "general_operand" "=do")
  1434.     (unsigned_fix:SI (match_operand:XF 1 "general_operand" "ro")))]
  1435.   "TARGET_SANE"
  1436.   "* return output_lib_convert(operands, \"_XTOU\");")
  1437.  
  1438. (define_insn ""
  1439.   [(set (match_operand:SI 0 "general_operand" "=do")
  1440.     (unsigned_fix:SI (match_operand:XF 1 "general_operand" "f")))]
  1441.   "TARGET_68881"
  1442.   "fmove%.l %1,%0")
  1443. ; was  "* return output_lib_convert(operands, \"_X96TOU\");")
  1444.  
  1445. ;; add instructions
  1446.  
  1447. ;; Note that the last two alternatives are near-duplicates
  1448. ;; in order to handle insns generated by reload.
  1449. ;; This is needed since they are not themselves reloaded,
  1450. ;; so commutativity won't apply to them.
  1451. (define_insn "addsi3"
  1452.   [(set (match_operand:SI 0 "general_operand" "=m,r,!a,!a")
  1453.     (plus:SI (match_operand:SI 1 "general_operand" "%0,0,a,rJK")
  1454.          (match_operand:SI 2 "general_operand" "dIKLM,mrIKLM,rJK,a")))]
  1455.   ""
  1456.   "*
  1457. {
  1458.   if (! operands_match_p (operands[0], operands[1]))
  1459.     {
  1460.       if (!ADDRESS_REG_P (operands[1]))
  1461.     {
  1462.       rtx tmp = operands[1];
  1463.  
  1464.       operands[1] = operands[2];
  1465.       operands[2] = tmp;
  1466.     }
  1467.  
  1468.       /* These insns can result from reloads to access
  1469.      stack slots over 64k from the frame pointer.  */
  1470.       if (GET_CODE (operands[2]) == CONST_INT
  1471.       && INTVAL (operands[2]) + 0x8000 >= (unsigned) 0x10000)
  1472.         return \"move%.l %2,%0\;add%.l %1,%0\";
  1473.       if (GET_CODE (operands[2]) == REG)
  1474.     return TARGET_GAS?\"lea %1@(%2:l),%0\":\"lea (%1,%2.l),%0\";
  1475.       else
  1476.     return TARGET_GAS?\"lea %1@(%c2),%0\":\"lea (%c2,%1),%0\";
  1477.     }
  1478.   if (GET_CODE (operands[2]) == CONST_INT)
  1479.     {
  1480.       if (INTVAL (operands[2]) > 0
  1481.       && INTVAL (operands[2]) <= 8)
  1482.     return (ADDRESS_REG_P (operands[0])
  1483.         ? \"addq%.w %2,%0\"
  1484.         : \"addq%.l %2,%0\");
  1485.       if (INTVAL (operands[2]) < 0
  1486.       && INTVAL (operands[2]) >= -8)
  1487.         {
  1488.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  1489.                      - INTVAL (operands[2]));
  1490.       return (ADDRESS_REG_P (operands[0])
  1491.           ? \"subq%.w %2,%0\"
  1492.           : \"subq%.l %2,%0\");
  1493.     }
  1494.       if (ADDRESS_REG_P (operands[0])
  1495.       && INTVAL (operands[2]) >= -0x8000
  1496.       && INTVAL (operands[2]) < 0x8000)
  1497.     return \"add%.w %2,%0\";
  1498.     }
  1499.   return \"add%.l %2,%0\";
  1500. }")
  1501.  
  1502. (define_insn ""
  1503.   [(set (match_operand:SI 0 "general_operand" "=a")
  1504.     (plus:SI (match_operand:SI 1 "general_operand" "0")
  1505.          (sign_extend:SI (match_operand:HI 2 "general_operand" "rmn"))))]
  1506.   ""
  1507.   "add%.w %2,%0")
  1508.  
  1509. (define_insn "addhi3"
  1510.   [(set (match_operand:HI 0 "general_operand" "=m,r")
  1511.     (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
  1512.          (match_operand:HI 2 "general_operand" "dn,rmn")))]
  1513.   ""
  1514.   "*
  1515. {
  1516.   if (GET_CODE (operands[2]) == CONST_INT)
  1517.     {
  1518.       if (INTVAL (operands[2]) > 0
  1519.       && INTVAL (operands[2]) <= 8)
  1520.     return \"addq%.w %2,%0\";
  1521.     }
  1522.   if (GET_CODE (operands[2]) == CONST_INT)
  1523.     {
  1524.       if (INTVAL (operands[2]) < 0
  1525.       && INTVAL (operands[2]) >= -8)
  1526.     {
  1527.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  1528.                      - INTVAL (operands[2]));
  1529.       return \"subq%.w %2,%0\";
  1530.     }
  1531.     }
  1532.   return \"add%.w %2,%0\";
  1533. }")
  1534.  
  1535. (define_insn ""
  1536.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  1537.     (plus:HI (match_dup 0)
  1538.          (match_operand:HI 1 "general_operand" "dn,rmn")))]
  1539.   ""
  1540.   "add%.w %1,%0")
  1541.  
  1542. (define_insn "addqi3"
  1543.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  1544.     (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
  1545.          (match_operand:QI 2 "general_operand" "dn,dmn")))]
  1546.   ""
  1547.   "*
  1548. {
  1549.   if (GET_CODE (operands[2]) == CONST_INT)
  1550.     {
  1551.       if (INTVAL (operands[2]) > 0
  1552.       && INTVAL (operands[2]) <= 8)
  1553.     return \"addq%.b %2,%0\";
  1554.     }
  1555.   if (GET_CODE (operands[2]) == CONST_INT)
  1556.     {
  1557.       if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
  1558.        {
  1559.      operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]));
  1560.      return \"subq%.b %2,%0\";
  1561.        }
  1562.     }
  1563.   return \"add%.b %2,%0\";
  1564. }")
  1565.  
  1566. (define_insn ""
  1567.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  1568.     (plus:QI (match_dup 0)
  1569.          (match_operand:QI 1 "general_operand" "dn,dmn")))]
  1570.   ""
  1571.   "add%.b %1,%0")
  1572.  
  1573. (define_expand "addsf3"
  1574.   [(set (match_operand:SF 0 "general_operand" "")
  1575.     (plus:SF (match_operand:SF 1 "general_operand" "")
  1576.          (match_operand:SF 2 "general_operand" "")))]
  1577.   "TARGET_SANE || TARGET_68881"
  1578.   "")
  1579.  
  1580. (define_insn ""
  1581.   [(set (match_operand:SF 0 "general_operand" "=f")
  1582.     (plus:SF (match_operand:SF 1 "general_operand" "%0")
  1583.          (match_operand:SF 2 "general_operand" "dfmF")))]
  1584.   "TARGET_68881"
  1585.   "*
  1586. {
  1587.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  1588.     return \"fadd%.x %2,%0\";
  1589.   return \"fadd%.s%2,%0\";
  1590. }")
  1591.  
  1592. (define_insn ""
  1593.   [(set (match_operand:SF 0 "general_operand" "=ro")
  1594.     (plus:SF (match_operand:SF 1 "general_operand" "%0")
  1595.          (match_operand:SF 2 "general_operand" "ro")))]
  1596.   "TARGET_SANE"
  1597.   "* return output_sane_3 (operands, 0x1000, \"FADDS\");")
  1598.  
  1599. (define_expand "adddf3"
  1600.   [(set (match_operand:DF 0 "general_operand" "")
  1601.     (plus:DF (match_operand:DF 1 "general_operand" "")
  1602.          (match_operand:DF 2 "general_operand" "")))]
  1603.   "TARGET_SANE || TARGET_68881"
  1604.   "")
  1605.  
  1606. (define_insn ""
  1607.   [(set (match_operand:DF 0 "general_operand" "=f")
  1608.     (plus:DF (match_operand:DF 1 "general_operand" "%0")
  1609.          (match_operand:DF 2 "general_operand" "fmF")))]
  1610.   "TARGET_68881"
  1611.   "*
  1612. {
  1613.   if (REG_P (operands[2]))
  1614.     return \"fadd%.x %2,%0\";
  1615.   return \"fadd%.d %2,%0\";
  1616. }")
  1617.  
  1618. (define_insn ""
  1619.   [(set (match_operand:DF 0 "general_operand" "=ro")
  1620.     (plus:DF (match_operand:DF 1 "general_operand" "%0")
  1621.          (match_operand:DF 2 "general_operand" "ro")))]
  1622.   "TARGET_SANE"
  1623.   "* return output_sane_3 (operands, 0x0800, \"FADDD\");")
  1624.  
  1625. (define_expand "addxf3"
  1626.   [(set (match_operand:XF 0 "general_operand" "")
  1627.     (plus:XF (match_operand:XF 1 "general_operand" "")
  1628.          (match_operand:XF 2 "general_operand" "")))]
  1629.   "TARGET_SANE || TARGET_68881"
  1630.   "")
  1631.  
  1632. (define_insn ""
  1633.   [(set (match_operand:XF 0 "general_operand" "=f")
  1634.     (plus:XF (match_operand:XF 1 "general_operand" "%0")
  1635.          (match_operand:XF 2 "general_operand" "fmG")))]
  1636.   "TARGET_68881"
  1637.   "fadd%.x %2,%0")
  1638.  
  1639. (define_insn ""
  1640.   [(set (match_operand:XF 0 "general_operand" "=ro")
  1641.     (plus:XF (match_operand:XF 1 "general_operand" "%0")
  1642.          (match_operand:XF 2 "general_operand" "ro")))]
  1643.   "TARGET_SANE"
  1644.   "* return output_sane_3 (operands, 0x0000, \"FADDX\");")
  1645.  
  1646. ;; subtract instructions
  1647.  
  1648. (define_insn "subsi3"
  1649.   [(set (match_operand:SI 0 "general_operand" "=m,r,!a,?d")
  1650.     (minus:SI (match_operand:SI 1 "general_operand" "0,0,a,mrIKs")
  1651.           (match_operand:SI 2 "general_operand" "dIKs,mrIKs,J,0")))]
  1652.   ""
  1653.   "*
  1654. {
  1655.   if (! operands_match_p (operands[0], operands[1]))
  1656.     {
  1657.       if (operands_match_p (operands[0], operands[2]))
  1658.     {
  1659.       if (GET_CODE (operands[1]) == CONST_INT)
  1660.         {
  1661.           if (INTVAL (operands[1]) > 0
  1662.           && INTVAL (operands[1]) <= 8)
  1663.         return \"subq%.l %1,%0\;neg%.l %0\";
  1664.         }
  1665.       return \"sub%.l %1,%0\;neg%.l %0\";
  1666.     }
  1667.       /* This case is matched by J, but negating -0x8000
  1668.          in an lea would give an invalid displacement.
  1669.      So do this specially.  */
  1670.       if (INTVAL (operands[2]) == -0x8000)
  1671.     return \"move%.l %1,%0\;sub%.l %2,%0\";
  1672.       return TARGET_GAS?\"lea %1@(%n2),%0\":\"lea (%n2,%1),%0\";
  1673.     }
  1674.   if (GET_CODE (operands[2]) == CONST_INT)
  1675.     {
  1676.       if (INTVAL (operands[2]) > 0
  1677.       && INTVAL (operands[2]) <= 8)
  1678.     return \"subq%.l %2,%0\";
  1679.       if (ADDRESS_REG_P (operands[0])
  1680.       && INTVAL (operands[2]) >= -0x8000
  1681.       && INTVAL (operands[2]) < 0x8000)
  1682.     return \"sub%.w %2,%0\";
  1683.     }
  1684.   if (GET_CODE (operands[2]) == SYMBOL_REF)
  1685.     {
  1686.       return \"pea %a2\;sub%.l %+,%0\";
  1687.     }
  1688.   return \"sub%.l %2,%0\";
  1689. }")
  1690.  
  1691. (define_insn ""
  1692.   [(set (match_operand:SI 0 "general_operand" "=a")
  1693.     (minus:SI (match_operand:SI 1 "general_operand" "0")
  1694.           (sign_extend:SI (match_operand:HI 2 "general_operand" "rmn"))))]
  1695.   ""
  1696.   "sub%.w %2,%0")
  1697.  
  1698. (define_insn "subhi3"
  1699.   [(set (match_operand:HI 0 "general_operand" "=m,r")
  1700.     (minus:HI (match_operand:HI 1 "general_operand" "0,0")
  1701.           (match_operand:HI 2 "general_operand" "dn,rmn")))]
  1702.   ""
  1703.   "sub%.w %2,%0")
  1704.  
  1705. (define_insn ""
  1706.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  1707.     (minus:HI (match_dup 0)
  1708.           (match_operand:HI 1 "general_operand" "dn,rmn")))]
  1709.   ""
  1710.   "sub%.w %1,%0")
  1711.  
  1712. (define_insn "subqi3"
  1713.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  1714.     (minus:QI (match_operand:QI 1 "general_operand" "0,0")
  1715.           (match_operand:QI 2 "general_operand" "dn,dmn")))]
  1716.   ""
  1717.   "sub%.b %2,%0")
  1718.  
  1719. (define_insn ""
  1720.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  1721.     (minus:QI (match_dup 0)
  1722.           (match_operand:QI 1 "general_operand" "dn,dmn")))]
  1723.   ""
  1724.   "sub%.b %1,%0")
  1725.  
  1726. (define_expand "subsf3"
  1727.   [(set (match_operand:SF 0 "general_operand" "")
  1728.     (minus:SF (match_operand:SF 1 "general_operand" "")
  1729.           (match_operand:SF 2 "general_operand" "")))]
  1730.   "TARGET_SANE || TARGET_68881"
  1731.   "")
  1732.  
  1733. (define_insn ""
  1734.   [(set (match_operand:SF 0 "general_operand" "=f")
  1735.     (minus:SF (match_operand:SF 1 "general_operand" "0")
  1736.           (match_operand:SF 2 "general_operand" "dfmF")))]
  1737.   "TARGET_68881"
  1738.   "*
  1739. {
  1740.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  1741.     return \"fsub%.x %2,%0\";
  1742.   return \"fsub%.s%2,%0\";
  1743. }")
  1744.  
  1745. (define_insn ""
  1746.   [(set (match_operand:SF 0 "general_operand" "=ro")
  1747.     (minus:SF (match_operand:SF 1 "general_operand" "0")
  1748.           (match_operand:SF 2 "general_operand" "ro")))]
  1749.   "TARGET_SANE"
  1750.   "* return output_sane_3 (operands, 0x1002, \"FSUBS\");")
  1751.  
  1752. (define_expand "subdf3"
  1753.   [(set (match_operand:DF 0 "general_operand" "")
  1754.     (minus:DF (match_operand:DF 1 "general_operand" "")
  1755.           (match_operand:DF 2 "general_operand" "")))]
  1756.   "TARGET_SANE || TARGET_68881"
  1757.   "")
  1758.  
  1759. (define_insn ""
  1760.   [(set (match_operand:DF 0 "general_operand" "=f")
  1761.     (minus:DF (match_operand:DF 1 "general_operand" "0")
  1762.           (match_operand:DF 2 "general_operand" "fmF")))]
  1763.   "TARGET_68881"
  1764.   "*
  1765. {
  1766.   if (REG_P (operands[2]))
  1767.     return \"fsub%.x %2,%0\";
  1768.   return \"fsub%.d %2,%0\";
  1769. }")
  1770.  
  1771. (define_insn ""
  1772.   [(set (match_operand:DF 0 "general_operand" "=ro")
  1773.     (minus:DF (match_operand:DF 1 "general_operand" "0")
  1774.           (match_operand:DF 2 "general_operand" "ro")))]
  1775.   "TARGET_SANE"
  1776.   "* return output_sane_3 (operands, 0x0802, \"FSUBD\");")
  1777.  
  1778. (define_expand "subxf3"
  1779.   [(set (match_operand:XF 0 "general_operand" "")
  1780.     (minus:XF (match_operand:XF 1 "general_operand" "")
  1781.           (match_operand:XF 2 "general_operand" "")))]
  1782.   "TARGET_SANE || TARGET_68881"
  1783.   "")
  1784.  
  1785. (define_insn ""
  1786.   [(set (match_operand:XF 0 "general_operand" "=f")
  1787.     (minus:XF (match_operand:XF 1 "general_operand" "0")
  1788.           (match_operand:XF 2 "general_operand" "fmG")))]
  1789.   "TARGET_68881"
  1790.   "fsub%.x %2,%0")
  1791.  
  1792. (define_insn ""
  1793.   [(set (match_operand:XF 0 "general_operand" "=ro")
  1794.     (minus:XF (match_operand:XF 1 "general_operand" "0")
  1795.           (match_operand:XF 2 "general_operand" "ro")))]
  1796.   "TARGET_SANE"
  1797.   "* return output_sane_3 (operands, 0x0002, \"FSUBX\");")
  1798.  
  1799. ;; multiply instructions
  1800.  
  1801. (define_insn "mulhi3"
  1802.   [(set (match_operand:HI 0 "general_operand" "=d")
  1803.     (mult:HI (match_operand:HI 1 "general_operand" "%0")
  1804.          (match_operand:HI 2 "general_operand" "dmn")))]
  1805.   ""
  1806.   "muls%.w %2,%0")
  1807.  
  1808. (define_insn "mulhisi3"
  1809.   [(set (match_operand:SI 0 "general_operand" "=d")
  1810.     (mult:SI (match_operand:HI 1 "general_operand" "%0")
  1811.          (match_operand:HI 2 "general_operand" "dmn")))]
  1812.   ""
  1813.   "muls%.w %2,%0")
  1814.  
  1815. (define_expand "mulsi3"
  1816.   [(set (match_operand:SI 0 "general_operand" "")
  1817.     (mult:SI (match_operand:SI 1 "general_operand" "")
  1818.          (match_operand:SI 2 "general_operand" "")))]
  1819.   "TARGET_INTLIB || TARGET_68020"
  1820.   "")
  1821.  
  1822. (define_insn ""
  1823.   [(set (match_operand:SI 0 "general_operand" "=d")
  1824.     (mult:SI (match_operand:SI 1 "general_operand" "%0")
  1825.          (match_operand:SI 2 "general_operand" "dmsK")))]
  1826.   "TARGET_68020"
  1827.   "muls%.l %2,%0")
  1828.  
  1829. (define_insn ""
  1830.   [(set (match_operand:SI 0 "general_operand" "=d")
  1831.     (mult:SI (match_operand:SI 1 "general_operand" "%0")
  1832.          (match_operand:SI 2 "general_operand" "dsK")))]
  1833.   "TARGET_INTLIB"
  1834.   "* return output_int_lib_call (operands, \"ULMULT\");")
  1835.  
  1836. (define_insn "umulhi3"
  1837.   [(set (match_operand:HI 0 "general_operand" "=d")
  1838.     (umult:HI (match_operand:HI 1 "general_operand" "%0")
  1839.           (match_operand:HI 2 "general_operand" "dmn")))]
  1840.   ""
  1841.   "mulu%.w %2,%0")
  1842.  
  1843. (define_insn "umulhisi3"
  1844.   [(set (match_operand:SI 0 "general_operand" "=d")
  1845.     (umult:SI (match_operand:HI 1 "general_operand" "%0")
  1846.           (match_operand:HI 2 "general_operand" "dmn")))]
  1847.   ""
  1848.   "mulu%.w %2,%0")
  1849.  
  1850. (define_expand "umulsi3"
  1851.   [(set (match_operand:SI 0 "general_operand" "")
  1852.     (umult:SI (match_operand:SI 1 "general_operand" "")
  1853.           (match_operand:SI 2 "general_operand" "")))]
  1854.   "TARGET_INTLIB || TARGET_68020"
  1855.   "")
  1856.  
  1857. (define_insn ""
  1858.   [(set (match_operand:SI 0 "general_operand" "=d")
  1859.     (umult:SI (match_operand:SI 1 "general_operand" "%0")
  1860.           (match_operand:SI 2 "general_operand" "dmsK")))]
  1861.   "TARGET_68020"
  1862.   "mulu%.l %2,%0")
  1863.  
  1864. (define_insn ""
  1865.   [(set (match_operand:SI 0 "general_operand" "=d")
  1866.     (umult:SI (match_operand:SI 1 "general_operand" "%0")
  1867.           (match_operand:SI 2 "general_operand" "dsK")))]
  1868.   "TARGET_INTLIB"
  1869.   "* return output_int_lib_call (operands, \"ULMULT\");")
  1870.  
  1871. (define_expand "mulsf3"
  1872.   [(set (match_operand:SF 0 "general_operand" "")
  1873.     (mult:SF (match_operand:SF 1 "general_operand" "")
  1874.          (match_operand:SF 2 "general_operand" "")))]
  1875.   "TARGET_SANE || TARGET_68881"
  1876.   "")
  1877.  
  1878. (define_insn ""
  1879.   [(set (match_operand:SF 0 "general_operand" "=f")
  1880.     (mult:SF (match_operand:SF 1 "general_operand" "%0")
  1881.          (match_operand:SF 2 "general_operand" "dfmF")))]
  1882.   "TARGET_68881"
  1883.   "*
  1884. {
  1885.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  1886.     return \"fsglmul%.x %2,%0\";
  1887.   return \"fsglmul%.s%2,%0\";
  1888. }")
  1889.  
  1890. (define_insn ""
  1891.   [(set (match_operand:SF 0 "general_operand" "=ro")
  1892.     (mult:SF (match_operand:SF 1 "general_operand" "%0")
  1893.          (match_operand:SF 2 "general_operand" "ro")))]
  1894.   "TARGET_SANE"
  1895.   "* return output_sane_3 (operands, 0x1004, \"FMULS\");")
  1896.  
  1897. (define_expand "muldf3"
  1898.   [(set (match_operand:DF 0 "general_operand" "")
  1899.     (mult:DF (match_operand:DF 1 "general_operand" "")
  1900.          (match_operand:DF 2 "general_operand" "")))]
  1901.   "TARGET_SANE || TARGET_68881"
  1902.   "")
  1903.  
  1904. (define_insn ""
  1905.   [(set (match_operand:DF 0 "general_operand" "=f")
  1906.     (mult:DF (match_operand:DF 1 "general_operand" "%0")
  1907.          (match_operand:DF 2 "general_operand" "fmF")))]
  1908.   "TARGET_68881"
  1909.   "*
  1910. {
  1911.   if (REG_P (operands[2]))
  1912.     return \"fmul%.x %2,%0\";
  1913.   return \"fmul%.d %2,%0\";
  1914. }")
  1915.  
  1916. (define_insn ""
  1917.   [(set (match_operand:DF 0 "general_operand" "=ro")
  1918.     (mult:DF (match_operand:DF 1 "general_operand" "%0")
  1919.          (match_operand:DF 2 "general_operand" "ro")))]
  1920.   "TARGET_SANE"
  1921.   "* return output_sane_3 (operands, 0x0804, \"FMULD\");")
  1922.  
  1923. (define_expand "mulxf3"
  1924.   [(set (match_operand:XF 0 "general_operand" "")
  1925.     (mult:XF (match_operand:XF 1 "general_operand" "")
  1926.          (match_operand:XF 2 "general_operand" "")))]
  1927.   "TARGET_SANE || TARGET_68881"
  1928.   "")
  1929.  
  1930. (define_insn ""
  1931.   [(set (match_operand:XF 0 "general_operand" "=f")
  1932.     (mult:XF (match_operand:XF 1 "general_operand" "%0")
  1933.          (match_operand:XF 2 "general_operand" "fmG")))]
  1934.   "TARGET_68881"
  1935.   "fmul%.x %2,%0")
  1936.  
  1937. (define_insn ""
  1938.   [(set (match_operand:XF 0 "general_operand" "=ro")
  1939.     (mult:XF (match_operand:XF 1 "general_operand" "%0")
  1940.          (match_operand:XF 2 "general_operand" "ro")))]
  1941.   "TARGET_SANE"
  1942.   "* return output_sane_3 (operands, 0x0004, \"FMULX\");")
  1943.  
  1944. ;; divide instructions
  1945.  
  1946. (define_insn "divhi3"
  1947.   [(set (match_operand:HI 0 "general_operand" "=d")
  1948.     (div:HI (match_operand:HI 1 "general_operand" "0")
  1949.         (match_operand:HI 2 "general_operand" "dmn")))]
  1950.   ""
  1951.   "ext%.l %0\;divs%.w %2,%0")
  1952.  
  1953. (define_insn "divhisi3"
  1954.   [(set (match_operand:HI 0 "general_operand" "=d")
  1955.     (div:HI (match_operand:SI 1 "general_operand" "0")
  1956.         (match_operand:HI 2 "general_operand" "dmn")))]
  1957.   ""
  1958.   "divs%.w %2,%0")
  1959.  
  1960. (define_expand "divsi3"
  1961.   [(set (match_operand:SI 0 "general_operand" "")
  1962.     (div:SI (match_operand:SI 1 "general_operand" "")
  1963.         (match_operand:SI 2 "general_operand" "")))]
  1964.   "TARGET_INTLIB || TARGET_68020"
  1965.   "")
  1966.  
  1967. (define_insn ""
  1968.   [(set (match_operand:SI 0 "general_operand" "=d")
  1969.     (div:SI (match_operand:SI 1 "general_operand" "0")
  1970.         (match_operand:SI 2 "general_operand" "dmsK")))]
  1971.   "TARGET_68020"
  1972.   "divs%.l %2,%0")
  1973.  
  1974. (define_insn ""
  1975.   [(set (match_operand:SI 0 "general_operand" "=d")
  1976.     (div:SI (match_operand:SI 1 "general_operand" "0")
  1977.         (match_operand:SI 2 "general_operand" "dsK")))]
  1978.   "TARGET_INTLIB"
  1979.   "* return output_int_lib_call (operands, \"SLDIVT\");")
  1980.  
  1981. (define_insn "udivhi3"
  1982.   [(set (match_operand:HI 0 "general_operand" "=d")
  1983.     (udiv:HI (match_operand:HI 1 "general_operand" "0")
  1984.          (match_operand:HI 2 "general_operand" "dmn")))]
  1985.   ""
  1986.   "and%.l #$FFFF,%0\;divu%.w %2,%0")
  1987.  
  1988. (define_insn "udivhisi3"
  1989.   [(set (match_operand:HI 0 "general_operand" "=d")
  1990.     (udiv:HI (match_operand:SI 1 "general_operand" "0")
  1991.          (match_operand:HI 2 "general_operand" "dmn")))]
  1992.   ""
  1993.   "divu%.w %2,%0")
  1994.  
  1995. (define_expand "udivsi3"
  1996.   [(set (match_operand:SI 0 "general_operand" "")
  1997.     (udiv:SI (match_operand:SI 1 "general_operand" "")
  1998.          (match_operand:SI 2 "general_operand" "")))]
  1999.   "TARGET_INTLIB || TARGET_68020"
  2000.   "")
  2001.  
  2002. (define_insn ""
  2003.   [(set (match_operand:SI 0 "general_operand" "=d")
  2004.     (udiv:SI (match_operand:SI 1 "general_operand" "0")
  2005.          (match_operand:SI 2 "general_operand" "dmsK")))]
  2006.   "TARGET_68020"
  2007.   "divu%.l %2,%0")
  2008.  
  2009. (define_insn ""
  2010.   [(set (match_operand:SI 0 "general_operand" "=d")
  2011.     (udiv:SI (match_operand:SI 1 "general_operand" "0")
  2012.          (match_operand:SI 2 "general_operand" "dsK")))]
  2013.   "TARGET_INTLIB"
  2014.   "* return output_int_lib_call (operands, \"ULDIVT\");")
  2015.  
  2016. (define_expand "divsf3"
  2017.   [(set (match_operand:SF 0 "general_operand" "")
  2018.     (div:SF (match_operand:SF 1 "general_operand" "")
  2019.          (match_operand:SF 2 "general_operand" "")))]
  2020.   "TARGET_SANE || TARGET_68881"
  2021.   "")
  2022.  
  2023. (define_insn ""
  2024.   [(set (match_operand:SF 0 "general_operand" "=f")
  2025.     (div:SF (match_operand:SF 1 "general_operand" "0")
  2026.          (match_operand:SF 2 "general_operand" "dfmF")))]
  2027.   "TARGET_68881"
  2028.   "*
  2029. {
  2030.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2031.     return \"fsgldiv%.x %2,%0\";
  2032.   return \"fsgldiv%.s%2,%0\";
  2033. }")
  2034.  
  2035. (define_insn ""
  2036.   [(set (match_operand:SF 0 "general_operand" "=ro")
  2037.     (div:SF (match_operand:SF 1 "general_operand" "0")
  2038.          (match_operand:SF 2 "general_operand" "ro")))]
  2039.   "TARGET_SANE"
  2040.   "* return output_sane_3 (operands, 0x1006, \"FDIVS\");")
  2041.  
  2042. (define_expand "divdf3"
  2043.   [(set (match_operand:DF 0 "general_operand" "")
  2044.     (div:DF (match_operand:DF 1 "general_operand" "")
  2045.          (match_operand:DF 2 "general_operand" "")))]
  2046.   "TARGET_SANE || TARGET_68881"
  2047.   "")
  2048.  
  2049. (define_insn ""
  2050.   [(set (match_operand:DF 0 "general_operand" "=f")
  2051.     (div:DF (match_operand:DF 1 "general_operand" "0")
  2052.          (match_operand:DF 2 "general_operand" "fmG")))]
  2053.   "TARGET_68881"
  2054.   "*
  2055. {
  2056.   if (REG_P (operands[2]))
  2057.     return \"fdiv%.x %2,%0\";
  2058.   return \"fdiv%.d %2,%0\";
  2059. }")
  2060.  
  2061. (define_insn ""
  2062.   [(set (match_operand:DF 0 "general_operand" "=ro")
  2063.     (div:DF (match_operand:DF 1 "general_operand" "0")
  2064.          (match_operand:DF 2 "general_operand" "ro")))]
  2065.   "TARGET_SANE"
  2066.   "* return output_sane_3 (operands, 0x0806, \"FDIVD\");")
  2067.  
  2068. (define_expand "divxf3"
  2069.   [(set (match_operand:XF 0 "general_operand" "")
  2070.     (div:XF (match_operand:XF 1 "general_operand" "")
  2071.          (match_operand:XF 2 "general_operand" "")))]
  2072.   "TARGET_SANE || TARGET_68881"
  2073.   "")
  2074.  
  2075. (define_insn ""
  2076.   [(set (match_operand:XF 0 "general_operand" "=f")
  2077.     (div:XF (match_operand:XF 1 "general_operand" "0")
  2078.          (match_operand:XF 2 "general_operand" "fmG")))]
  2079.   "TARGET_68881"
  2080.   "fdiv%.x %2,%0")
  2081.  
  2082. (define_insn ""
  2083.   [(set (match_operand:XF 0 "general_operand" "=ro")
  2084.     (div:XF (match_operand:XF 1 "general_operand" "0")
  2085.          (match_operand:XF 2 "general_operand" "ro")))]
  2086.   "TARGET_SANE"
  2087.   "* return output_sane_3 (operands, 0x0006, \"FDIVX\");")
  2088.  
  2089. ;; Remainder instructions.
  2090.  
  2091. (define_insn "modhi3"
  2092.   [(set (match_operand:HI 0 "general_operand" "=d")
  2093.     (mod:HI (match_operand:HI 1 "general_operand" "0")
  2094.         (match_operand:HI 2 "general_operand" "dmn")))]
  2095.   ""
  2096.   "*
  2097. {
  2098.   /* The swap insn produces cc's that don't correspond to the result.  */
  2099.   CC_STATUS_INIT;
  2100.   return \"ext%.l %0\;divs%.w %2,%0\;swap %0\";
  2101. }")
  2102.  
  2103. (define_insn "modhisi3"
  2104.   [(set (match_operand:HI 0 "general_operand" "=d")
  2105.     (mod:HI (match_operand:SI 1 "general_operand" "0")
  2106.         (match_operand:HI 2 "general_operand" "dmn")))]
  2107.   ""
  2108.   "*
  2109. {
  2110.   /* The swap insn produces cc's that don't correspond to the result.  */
  2111.   CC_STATUS_INIT;
  2112.   return \"divs%.w %2,%0\;swap %0\";
  2113. }")
  2114.  
  2115. (define_insn "umodhi3"
  2116.   [(set (match_operand:HI 0 "general_operand" "=d")
  2117.     (umod:HI (match_operand:HI 1 "general_operand" "0")
  2118.          (match_operand:HI 2 "general_operand" "dmn")))]
  2119.   ""
  2120.   "*
  2121. {
  2122.   /* The swap insn produces cc's that don't correspond to the result.  */
  2123.   CC_STATUS_INIT;
  2124.   return \"and%.l #$FFFF,%0\;divu%.w %2,%0\;swap %0\";
  2125. }")
  2126.  
  2127. (define_insn "umodhisi3"
  2128.   [(set (match_operand:HI 0 "general_operand" "=d")
  2129.     (umod:HI (match_operand:SI 1 "general_operand" "0")
  2130.          (match_operand:HI 2 "general_operand" "dmn")))]
  2131.   ""
  2132.   "*
  2133. {
  2134.   /* The swap insn produces cc's that don't correspond to the result.  */
  2135.   CC_STATUS_INIT;
  2136.   return \"divu%.w %2,%0\;swap %0\";
  2137. }")
  2138.  
  2139. (define_insn "divmodsi4"
  2140.   [(set (match_operand:SI 0 "general_operand" "=d")
  2141.     (div:SI (match_operand:SI 1 "general_operand" "0")
  2142.         (match_operand:SI 2 "general_operand" "dmsK")))
  2143.    (set (match_operand:SI 3 "general_operand" "=d")
  2144.     (mod:SI (match_dup 1) (match_dup 2)))]
  2145.   "TARGET_68020"
  2146.   "tdivs%.l %2,%3:%0")
  2147.  
  2148. (define_insn "udivmodsi4"
  2149.   [(set (match_operand:SI 0 "general_operand" "=d")
  2150.     (udiv:SI (match_operand:SI 1 "general_operand" "0")
  2151.          (match_operand:SI 2 "general_operand" "dmsK")))
  2152.    (set (match_operand:SI 3 "general_operand" "=d")
  2153.     (umod:SI (match_dup 1) (match_dup 2)))]
  2154.   "TARGET_68020"
  2155.   "tdivu%.l %2,%3:%0")
  2156.  
  2157. ;; logical-and instructions
  2158.  
  2159. (define_insn "andsi3"
  2160.   [(set (match_operand:SI 0 "general_operand" "=m,d")
  2161.     (and:SI (match_operand:SI 1 "general_operand" "%0,0")
  2162.         (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  2163.   ""
  2164.   "*
  2165. {
  2166.   if (GET_CODE (operands[2]) == CONST_INT
  2167.       && (INTVAL (operands[2]) | 0xffff) == 0xffffffff
  2168.       && (DATA_REG_P (operands[0])
  2169.       || offsettable_memref_p (operands[0])))
  2170.     { 
  2171.       if (GET_CODE (operands[0]) != REG)
  2172.         operands[0] = adj_offsettable_operand (operands[0], 2);
  2173.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  2174.                  INTVAL (operands[2]) & 0xffff);
  2175.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  2176.       CC_STATUS_INIT;
  2177.       if (operands[2] == const0_rtx)
  2178.         return \"clr%.w %0\";
  2179.       return \"and%.w %2,%0\";
  2180.     }
  2181.   return \"and%.l %2,%0\";
  2182. }")
  2183.  
  2184. (define_insn "andhi3"
  2185.   [(set (match_operand:HI 0 "general_operand" "=m,d")
  2186.     (and:HI (match_operand:HI 1 "general_operand" "%0,0")
  2187.         (match_operand:HI 2 "general_operand" "dn,dmn")))]
  2188.   ""
  2189.   "and%.w %2,%0")
  2190.  
  2191. (define_insn "andqi3"
  2192.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  2193.     (and:QI (match_operand:QI 1 "general_operand" "%0,0")
  2194.         (match_operand:QI 2 "general_operand" "dn,dmn")))]
  2195.   ""
  2196.   "and%.b %2,%0")
  2197.  
  2198. (define_insn ""
  2199.   [(set (match_operand:SI 0 "general_operand" "=d")
  2200.     (and:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "dm"))
  2201.         (match_operand:SI 2 "general_operand" "0")))]
  2202.   "GET_CODE (operands[2]) == CONST_INT
  2203.    && (unsigned int) INTVAL (operands[2]) < (1 << GET_MODE_BITSIZE (HImode))"
  2204.   "and%.w %1,%0")
  2205.  
  2206. (define_insn ""
  2207.   [(set (match_operand:SI 0 "general_operand" "=d")
  2208.     (and:SI (zero_extend:SI (match_operand:QI 1 "general_operand" "dm"))
  2209.         (match_operand:SI 2 "general_operand" "0")))]
  2210.   "GET_CODE (operands[2]) == CONST_INT
  2211.    && (unsigned int) INTVAL (operands[2]) < (1 << GET_MODE_BITSIZE (QImode))"
  2212.   "and%.b %1,%0")
  2213.  
  2214. ;; inclusive-or instructions
  2215.  
  2216. (define_insn "iorsi3"
  2217.   [(set (match_operand:SI 0 "general_operand" "=m,d")
  2218.     (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
  2219.         (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  2220.   ""
  2221.   "*
  2222. {
  2223.   register int logval;
  2224.   if (GET_CODE (operands[2]) == CONST_INT
  2225.       && INTVAL (operands[2]) >> 16 == 0
  2226.       && (DATA_REG_P (operands[0])
  2227.       || offsettable_memref_p (operands[0])))
  2228.     { 
  2229.       if (GET_CODE (operands[0]) != REG)
  2230.         operands[0] = adj_offsettable_operand (operands[0], 2);
  2231.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  2232.       CC_STATUS_INIT;
  2233.       return \"or%.w %2,%0\";
  2234.     }
  2235.   if (GET_CODE (operands[2]) == CONST_INT
  2236.       && (logval = exact_log2 (INTVAL (operands[2]))) >= 0
  2237.       && (DATA_REG_P (operands[0])
  2238.       || offsettable_memref_p (operands[0])))
  2239.     { 
  2240.       if (DATA_REG_P (operands[0]))
  2241.     {
  2242.       operands[1] = gen_rtx (CONST_INT, VOIDmode, logval);
  2243.     }
  2244.       else
  2245.         {
  2246.       operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8));
  2247.       operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8);
  2248.     }
  2249.       return \"bset %1,%0\";
  2250.     }
  2251.   return \"or%.l %2,%0\";
  2252. }")
  2253.  
  2254. (define_insn "iorhi3"
  2255.   [(set (match_operand:HI 0 "general_operand" "=m,d")
  2256.     (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
  2257.         (match_operand:HI 2 "general_operand" "dn,dmn")))]
  2258.   ""
  2259.   "or%.w %2,%0")
  2260.  
  2261. (define_insn "iorqi3"
  2262.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  2263.     (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
  2264.         (match_operand:QI 2 "general_operand" "dn,dmn")))]
  2265.   ""
  2266.   "or%.b %2,%0")
  2267.  
  2268. ;; xor instructions
  2269.  
  2270. (define_insn "xorsi3"
  2271.   [(set (match_operand:SI 0 "general_operand" "=do,m")
  2272.     (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
  2273.         (match_operand:SI 2 "general_operand" "di,dKs")))]
  2274.   ""
  2275.   "*
  2276. {
  2277.   if (GET_CODE (operands[2]) == CONST_INT
  2278.       && INTVAL (operands[2]) >> 16 == 0
  2279.       && (offsettable_memref_p (operands[0]) || DATA_REG_P (operands[0])))
  2280.     { 
  2281.       if (! DATA_REG_P (operands[0]))
  2282.     operands[0] = adj_offsettable_operand (operands[0], 2);
  2283.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  2284.       CC_STATUS_INIT;
  2285.       return \"eor%.w %2,%0\";
  2286.     }
  2287.   return \"eor%.l %2,%0\";
  2288. }")
  2289.  
  2290. (define_insn "xorhi3"
  2291.   [(set (match_operand:HI 0 "general_operand" "=dm")
  2292.     (xor:HI (match_operand:HI 1 "general_operand" "%0")
  2293.         (match_operand:HI 2 "general_operand" "dn")))]
  2294.   ""
  2295.   "eor%.w %2,%0")
  2296.  
  2297. (define_insn "xorqi3"
  2298.   [(set (match_operand:QI 0 "general_operand" "=dm")
  2299.     (xor:QI (match_operand:QI 1 "general_operand" "%0")
  2300.         (match_operand:QI 2 "general_operand" "dn")))]
  2301.   ""
  2302.   "eor%.b %2,%0")
  2303.  
  2304. ;; negation instructions
  2305.  
  2306. (define_insn "negsi2"
  2307.   [(set (match_operand:SI 0 "general_operand" "=dm")
  2308.     (neg:SI (match_operand:SI 1 "general_operand" "0")))]
  2309.   ""
  2310.   "neg%.l %0")
  2311.  
  2312. (define_insn "neghi2"
  2313.   [(set (match_operand:HI 0 "general_operand" "=dm")
  2314.     (neg:HI (match_operand:HI 1 "general_operand" "0")))]
  2315.   ""
  2316.   "neg%.w %0")
  2317.  
  2318. (define_insn "negqi2"
  2319.   [(set (match_operand:QI 0 "general_operand" "=dm")
  2320.     (neg:QI (match_operand:QI 1 "general_operand" "0")))]
  2321.   ""
  2322.   "neg%.b %0")
  2323.  
  2324. (define_expand "negsf2"
  2325.   [(set (match_operand:SF 0 "general_operand" "")
  2326.     (neg:SF (match_operand:SF 1 "general_operand" "")))]
  2327.   "TARGET_SANE || TARGET_68881"
  2328.   "")
  2329.  
  2330. (define_insn ""
  2331.   [(set (match_operand:SF 0 "general_operand" "=f")
  2332.     (neg:SF (match_operand:SF 1 "general_operand" "fmF")))]
  2333.   "TARGET_68881"
  2334.   "*
  2335. {
  2336.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  2337.     return \"fneg%.x %1,%0\";
  2338.   return \"fneg%.s%1,%0\";
  2339. }")
  2340.  
  2341. (define_insn ""
  2342.   [(set (match_operand:SF 0 "general_operand" "=ro")
  2343.     (neg:SF (match_operand:SF 1 "general_operand" "0")))]
  2344.   "TARGET_SANE"
  2345.   "* return output_sane_2 (operands, 0x000d, \"FNEGX\");")
  2346.  
  2347. (define_expand "negdf2"
  2348.   [(set (match_operand:DF 0 "general_operand" "")
  2349.     (neg:DF (match_operand:DF 1 "general_operand" "")))]
  2350.   "TARGET_SANE || TARGET_68881"
  2351.   "")
  2352.  
  2353. (define_insn ""
  2354.   [(set (match_operand:DF 0 "general_operand" "=f")
  2355.     (neg:DF (match_operand:DF 1 "general_operand" "fmG")))]
  2356.   "TARGET_68881"
  2357.   "*
  2358. {
  2359.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  2360.     return \"fneg%.x %1,%0\";
  2361.   return \"fneg%.d %1,%0\";
  2362. }")
  2363.  
  2364. (define_insn ""
  2365.   [(set (match_operand:DF 0 "general_operand" "=ro")
  2366.     (neg:DF (match_operand:DF 1 "general_operand" "0")))]
  2367.   "TARGET_SANE"
  2368.   "* return output_sane_2 (operands, 0x000d, \"FNEGX\");")
  2369.  
  2370. (define_expand "negxf2"
  2371.   [(set (match_operand:XF 0 "general_operand" "")
  2372.     (neg:XF (match_operand:XF 1 "general_operand" "")))]
  2373.   "TARGET_SANE || TARGET_68881"
  2374.   "")
  2375.  
  2376. (define_insn ""
  2377.   [(set (match_operand:XF 0 "general_operand" "=f")
  2378.     (neg:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2379.   "TARGET_68881"
  2380.   "fneg%.x %1,%0")
  2381.  
  2382. (define_insn ""
  2383.   [(set (match_operand:XF 0 "general_operand" "=ro")
  2384.     (neg:XF (match_operand:XF 1 "general_operand" "0")))]
  2385.   "TARGET_SANE"
  2386.   "* return output_sane_2 (operands, 0x000d, \"FNEGX\");")
  2387.  
  2388. ;; Assorted math function handling
  2389.  
  2390. (define_insn "sinxf2"
  2391.   [(set (match_operand:XF 0 "general_operand" "=f")
  2392.     (sin:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2393.   "TARGET_ELEMS881"
  2394.   "fsin%.x %1,%0")
  2395.  
  2396. (define_insn "cosxf2"
  2397.   [(set (match_operand:XF 0 "general_operand" "=f")
  2398.     (cos:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2399.   "TARGET_ELEMS881"
  2400.   "fcos%.x %1,%0")
  2401.  
  2402. (define_insn "tanxf2"
  2403.   [(set (match_operand:XF 0 "general_operand" "=f")
  2404.     (tan:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2405.   "TARGET_ELEMS881"
  2406.   "ftan%.x %1,%0")
  2407.  
  2408. (define_insn "asinxf2"
  2409.   [(set (match_operand:XF 0 "general_operand" "=f")
  2410.     (asin:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2411.   "TARGET_ELEMS881"
  2412.   "fasin%.x %1,%0")
  2413.  
  2414. (define_insn "acosxf2"
  2415.   [(set (match_operand:XF 0 "general_operand" "=f")
  2416.     (acos:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2417.   "TARGET_ELEMS881"
  2418.   "facos%.x %1,%0")
  2419.  
  2420. (define_insn "atanxf2"
  2421.   [(set (match_operand:XF 0 "general_operand" "=f")
  2422.     (atan:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2423.   "TARGET_ELEMS881"
  2424.   "fatan%.x %1,%0")
  2425.  
  2426. (define_insn "sinhxf2"
  2427.   [(set (match_operand:XF 0 "general_operand" "=f")
  2428.     (sinh:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2429.   "TARGET_ELEMS881"
  2430.   "fsinh%.x %1,%0")
  2431.  
  2432. (define_insn "coshxf2"
  2433.   [(set (match_operand:XF 0 "general_operand" "=f")
  2434.     (cosh:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2435.   "TARGET_ELEMS881"
  2436.   "fcosh%.x %1,%0")
  2437.  
  2438. (define_insn "tanhxf2"
  2439.   [(set (match_operand:XF 0 "general_operand" "=f")
  2440.     (tanh:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2441.   "TARGET_ELEMS881"
  2442.   "ftanh%.x %1,%0")
  2443.  
  2444. (define_insn "expxf2"
  2445.   [(set (match_operand:XF 0 "general_operand" "=f")
  2446.     (exp:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2447.   "TARGET_ELEMS881"
  2448.   "fetox%.x %1,%0")
  2449.  
  2450. (define_insn "logxf2"
  2451.   [(set (match_operand:XF 0 "general_operand" "=f")
  2452.     (log:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2453.   "TARGET_ELEMS881"
  2454.   "flogn%.x %1,%0")
  2455.  
  2456. (define_insn "log10xf2"
  2457.   [(set (match_operand:XF 0 "general_operand" "=f")
  2458.     (log10:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2459.   "TARGET_ELEMS881"
  2460.   "flog10%.x %1,%0")
  2461.  
  2462. (define_insn "sqrtxf2"
  2463.   [(set (match_operand:XF 0 "general_operand" "=f")
  2464.     (sqrt:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2465.   "TARGET_ELEMS881"
  2466.   "fsqrt%.x %1,%0")
  2467.  
  2468. ;; Don't bother trying to make SANE math calls directly, -elems881
  2469. ;; implies -mc68881 anyway.
  2470.  
  2471. ;; Absolute value instructions
  2472.  
  2473. (define_expand "abssf2"
  2474.   [(set (match_operand:SF 0 "general_operand" "")
  2475.     (abs:SF (match_operand:SF 1 "general_operand" "")))]
  2476.   "TARGET_SANE || TARGET_68881"
  2477.   "")
  2478.  
  2479. (define_insn ""
  2480.   [(set (match_operand:SF 0 "general_operand" "=f")
  2481.     (abs:SF (match_operand:SF 1 "general_operand" "fmF")))]
  2482.   "TARGET_68881"
  2483.   "*
  2484. {
  2485.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  2486.     return \"fabs%.x %1,%0\";
  2487.   return \"fabs%.s%1,%0\";
  2488. }")
  2489.  
  2490. (define_insn ""
  2491.   [(set (match_operand:SF 0 "general_operand" "=ro")
  2492.     (abs:SF (match_operand:SF 1 "general_operand" "0")))]
  2493.   "TARGET_SANE"
  2494.   "* return output_sane_2 (operands, 0x000f, \"FABSX\");")
  2495.  
  2496. (define_expand "absdf2"
  2497.   [(set (match_operand:DF 0 "general_operand" "")
  2498.     (abs:DF (match_operand:DF 1 "general_operand" "")))]
  2499.   "TARGET_SANE || TARGET_68881"
  2500.   "")
  2501.  
  2502. (define_insn ""
  2503.   [(set (match_operand:DF 0 "general_operand" "=f")
  2504.     (abs:DF (match_operand:DF 1 "general_operand" "fmG")))]
  2505.   "TARGET_68881"
  2506.   "*
  2507. {
  2508.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  2509.     return \"fabs%.x %1,%0\";
  2510.   return \"fabs%.d %1,%0\";
  2511. }")
  2512.  
  2513. (define_insn ""
  2514.   [(set (match_operand:DF 0 "general_operand" "=ro")
  2515.     (abs:DF (match_operand:DF 1 "general_operand" "0")))]
  2516.   "TARGET_SANE"
  2517.   "* return output_sane_2 (operands, 0x000f, \"FABSX\");")
  2518.  
  2519. (define_expand "absxf2"
  2520.   [(set (match_operand:XF 0 "general_operand" "")
  2521.     (abs:XF (match_operand:XF 1 "general_operand" "")))]
  2522.   "TARGET_SANE || TARGET_68881"
  2523.   "")
  2524.  
  2525. (define_insn ""
  2526.   [(set (match_operand:XF 0 "general_operand" "=f")
  2527.     (abs:XF (match_operand:XF 1 "general_operand" "fmG")))]
  2528.   "TARGET_68881"
  2529.   "fabs%.x %1,%0")
  2530.  
  2531. (define_insn ""
  2532.   [(set (match_operand:XF 0 "general_operand" "=ro")
  2533.     (abs:XF (match_operand:XF 1 "general_operand" "0")))]
  2534.   "TARGET_SANE"
  2535.   "* return output_sane_2 (operands, 0x000f, \"FABSX\");")
  2536.  
  2537. ;; one complement instructions
  2538.  
  2539. (define_insn "one_cmplsi2"
  2540.   [(set (match_operand:SI 0 "general_operand" "=dm")
  2541.     (not:SI (match_operand:SI 1 "general_operand" "0")))]
  2542.   ""
  2543.   "not%.l %0")
  2544.  
  2545. (define_insn "one_cmplhi2"
  2546.   [(set (match_operand:HI 0 "general_operand" "=dm")
  2547.     (not:HI (match_operand:HI 1 "general_operand" "0")))]
  2548.   ""
  2549.   "not%.w %0")
  2550.  
  2551. (define_insn "one_cmplqi2"
  2552.   [(set (match_operand:QI 0 "general_operand" "=dm")
  2553.     (not:QI (match_operand:QI 1 "general_operand" "0")))]
  2554.   ""
  2555.   "not%.b %0")
  2556.  
  2557. ;; Optimized special case of shifting.
  2558. ;; Must precede the general case.
  2559.  
  2560. (define_insn ""
  2561.   [(set (match_operand:SI 0 "general_operand" "=d")
  2562.     (ashiftrt:SI (match_operand:SI 1 "memory_operand" "m")
  2563.              (const_int 24)))]
  2564.   "GET_CODE (XEXP (operands[1], 0)) != POST_INC
  2565.    && GET_CODE (XEXP (operands[1], 0)) != PRE_DEC"
  2566.   "*
  2567. {
  2568.   if (TARGET_68020)
  2569.     return \"move%.b %1,%0\;extb%.l %0\";
  2570.   return \"move%.b %1,%0\;ext%.w %0\;ext%.l %0\";
  2571. }")
  2572.  
  2573. (define_insn ""
  2574.   [(set (match_operand:SI 0 "general_operand" "=d")
  2575.     (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
  2576.              (const_int 24)))]
  2577.   "GET_CODE (XEXP (operands[1], 0)) != POST_INC
  2578.    && GET_CODE (XEXP (operands[1], 0)) != PRE_DEC"
  2579.   "*
  2580. {
  2581.   if (reg_mentioned_p (operands[0], operands[1]))
  2582.     return \"move%.b %1,%0\;and%.l #$FF,%0\";
  2583.   return \"clr%.l %0\;move%.b %1,%0\";
  2584. }")
  2585.  
  2586. (define_insn ""
  2587.   [(set (cc0) (compare (match_operand:QI 0 "general_operand" "i")
  2588.                (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
  2589.                     (const_int 24))))]
  2590.   "(GET_CODE (operands[0]) == CONST_INT
  2591.     && (INTVAL (operands[0]) & ~0xff) == 0)"
  2592.   "* cc_status.flags |= CC_REVERSED;
  2593.   return \"cmp%.b %0,%1\";
  2594. ")
  2595.  
  2596. (define_insn ""
  2597.   [(set (cc0) (compare (lshiftrt:SI (match_operand:SI 0 "memory_operand" "m")
  2598.                     (const_int 24))
  2599.                (match_operand:QI 1 "general_operand" "i")))]
  2600.   "(GET_CODE (operands[1]) == CONST_INT
  2601.     && (INTVAL (operands[1]) & ~0xff) == 0)"
  2602.   "*
  2603.   return \"cmp%.b %1,%0\";
  2604. ")
  2605.  
  2606. (define_insn ""
  2607.   [(set (cc0) (compare (match_operand:QI 0 "general_operand" "i")
  2608.                (ashiftrt:SI (match_operand:SI 1 "memory_operand" "m")
  2609.                     (const_int 24))))]
  2610.   "(GET_CODE (operands[0]) == CONST_INT
  2611.     && ((INTVAL (operands[0]) + 0x80) & ~0xff) == 0)"
  2612.   "* cc_status.flags |= CC_REVERSED;
  2613.   return \"cmp%.b %0,%1\";
  2614. ")
  2615.  
  2616. (define_insn ""
  2617.   [(set (cc0) (compare (ashiftrt:SI (match_operand:SI 0 "memory_operand" "m")
  2618.                     (const_int 24))
  2619.                (match_operand:QI 1 "general_operand" "i")))]
  2620.   "(GET_CODE (operands[1]) == CONST_INT
  2621.     && ((INTVAL (operands[1]) + 0x80) & ~0xff) == 0)"
  2622.   "*
  2623.   return \"cmp%.b %1,%0\";
  2624. ")
  2625.  
  2626. ;; arithmetic shift instructions
  2627. ;; We don't need the shift memory by 1 bit instruction
  2628.  
  2629. (define_insn "ashlsi3"
  2630.   [(set (match_operand:SI 0 "general_operand" "=d")
  2631.     (ashift:SI (match_operand:SI 1 "general_operand" "0")
  2632.            (match_operand:SI 2 "general_operand" "dI")))]
  2633.   ""
  2634.   "asl%.l %2,%0")
  2635.  
  2636. (define_insn "ashlhi3"
  2637.   [(set (match_operand:HI 0 "general_operand" "=d")
  2638.     (ashift:HI (match_operand:HI 1 "general_operand" "0")
  2639.            (match_operand:HI 2 "general_operand" "dI")))]
  2640.   ""
  2641.   "asl%.w %2,%0")
  2642.  
  2643. (define_insn "ashlqi3"
  2644.   [(set (match_operand:QI 0 "general_operand" "=d")
  2645.     (ashift:QI (match_operand:QI 1 "general_operand" "0")
  2646.            (match_operand:QI 2 "general_operand" "dI")))]
  2647.   ""
  2648.   "asl%.b %2,%0")
  2649.  
  2650. (define_insn "ashrsi3"
  2651.   [(set (match_operand:SI 0 "general_operand" "=d")
  2652.     (ashiftrt:SI (match_operand:SI 1 "general_operand" "0")
  2653.              (match_operand:SI 2 "general_operand" "dI")))]
  2654.   ""
  2655.   "asr%.l %2,%0")
  2656.  
  2657. (define_insn "ashrhi3"
  2658.   [(set (match_operand:HI 0 "general_operand" "=d")
  2659.     (ashiftrt:HI (match_operand:HI 1 "general_operand" "0")
  2660.              (match_operand:HI 2 "general_operand" "dI")))]
  2661.   ""
  2662.   "asr%.w %2,%0")
  2663.  
  2664. (define_insn "ashrqi3"
  2665.   [(set (match_operand:QI 0 "general_operand" "=d")
  2666.     (ashiftrt:QI (match_operand:QI 1 "general_operand" "0")
  2667.              (match_operand:QI 2 "general_operand" "dI")))]
  2668.   ""
  2669.   "asr%.b %2,%0")
  2670.  
  2671. ;; logical shift instructions
  2672.  
  2673. (define_insn "lshlsi3"
  2674.   [(set (match_operand:SI 0 "general_operand" "=d")
  2675.     (lshift:SI (match_operand:SI 1 "general_operand" "0")
  2676.            (match_operand:SI 2 "general_operand" "dI")))]
  2677.   ""
  2678.   "lsl%.l %2,%0")
  2679.  
  2680. (define_insn "lshlhi3"
  2681.   [(set (match_operand:HI 0 "general_operand" "=d")
  2682.     (lshift:HI (match_operand:HI 1 "general_operand" "0")
  2683.            (match_operand:HI 2 "general_operand" "dI")))]
  2684.   ""
  2685.   "lsl%.w %2,%0")
  2686.  
  2687. (define_insn "lshlqi3"
  2688.   [(set (match_operand:QI 0 "general_operand" "=d")
  2689.     (lshift:QI (match_operand:QI 1 "general_operand" "0")
  2690.            (match_operand:QI 2 "general_operand" "dI")))]
  2691.   ""
  2692.   "lsl%.b %2,%0")
  2693.  
  2694. (define_insn "lshrsi3"
  2695.   [(set (match_operand:SI 0 "general_operand" "=d")
  2696.     (lshiftrt:SI (match_operand:SI 1 "general_operand" "0")
  2697.              (match_operand:SI 2 "general_operand" "dI")))]
  2698.   ""
  2699.   "lsr%.l %2,%0")
  2700.  
  2701. (define_insn "lshrhi3"
  2702.   [(set (match_operand:HI 0 "general_operand" "=d")
  2703.     (lshiftrt:HI (match_operand:HI 1 "general_operand" "0")
  2704.              (match_operand:HI 2 "general_operand" "dI")))]
  2705.   ""
  2706.   "lsr%.w %2,%0")
  2707.  
  2708. (define_insn "lshrqi3"
  2709.   [(set (match_operand:QI 0 "general_operand" "=d")
  2710.     (lshiftrt:QI (match_operand:QI 1 "general_operand" "0")
  2711.              (match_operand:QI 2 "general_operand" "dI")))]
  2712.   ""
  2713.   "lsr%.b %2,%0")
  2714.  
  2715. ;; rotate instructions
  2716.  
  2717. (define_insn "rotlsi3"
  2718.   [(set (match_operand:SI 0 "general_operand" "=d")
  2719.     (rotate:SI (match_operand:SI 1 "general_operand" "0")
  2720.            (match_operand:SI 2 "general_operand" "dI")))]
  2721.   ""
  2722.   "rol%.l %2,%0")
  2723.  
  2724. (define_insn "rotlhi3"
  2725.   [(set (match_operand:HI 0 "general_operand" "=d")
  2726.     (rotate:HI (match_operand:HI 1 "general_operand" "0")
  2727.            (match_operand:HI 2 "general_operand" "dI")))]
  2728.   ""
  2729.   "rol%.w %2,%0")
  2730.  
  2731. (define_insn "rotlqi3"
  2732.   [(set (match_operand:QI 0 "general_operand" "=d")
  2733.     (rotate:QI (match_operand:QI 1 "general_operand" "0")
  2734.            (match_operand:QI 2 "general_operand" "dI")))]
  2735.   ""
  2736.   "rol%.b %2,%0")
  2737.  
  2738. (define_insn "rotrsi3"
  2739.   [(set (match_operand:SI 0 "general_operand" "=d")
  2740.     (rotatert:SI (match_operand:SI 1 "general_operand" "0")
  2741.              (match_operand:SI 2 "general_operand" "dI")))]
  2742.   ""
  2743.   "ror%.l %2,%0")
  2744.  
  2745. (define_insn "rotrhi3"
  2746.   [(set (match_operand:HI 0 "general_operand" "=d")
  2747.     (rotatert:HI (match_operand:HI 1 "general_operand" "0")
  2748.              (match_operand:HI 2 "general_operand" "dI")))]
  2749.   ""
  2750.   "ror%.w %2,%0")
  2751.  
  2752. (define_insn "rotrqi3"
  2753.   [(set (match_operand:QI 0 "general_operand" "=d")
  2754.     (rotatert:QI (match_operand:QI 1 "general_operand" "0")
  2755.              (match_operand:QI 2 "general_operand" "dI")))]
  2756.   ""
  2757.   "ror%.b %2,%0")
  2758.  
  2759. ;; Special cases of bit-field insns which we should
  2760. ;; recognize in preference to the general case.
  2761. ;; These handle aligned 8-bit and 16-bit fields,
  2762. ;; which can usually be done with move instructions.
  2763.  
  2764. (define_insn ""
  2765.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+do")
  2766.              (match_operand:SI 1 "immediate_operand" "i")
  2767.              (match_operand:SI 2 "immediate_operand" "i"))
  2768.     (match_operand:SI 3 "general_operand" "d"))]
  2769.   "TARGET_68020 && TARGET_BITFIELD
  2770.    && GET_CODE (operands[1]) == CONST_INT
  2771.    && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
  2772.    && GET_CODE (operands[2]) == CONST_INT
  2773.    && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
  2774.    && (GET_CODE (operands[0]) == REG
  2775.        || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
  2776.   "*
  2777. {
  2778.   if (REG_P (operands[0]))
  2779.     {
  2780.       if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
  2781.         return \"bfins %3,%0{%b2:%b1}\";
  2782.     }
  2783.   else
  2784.     operands[0]
  2785.       = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8);
  2786.  
  2787.   if (GET_CODE (operands[3]) == MEM)
  2788.     operands[3] = adj_offsettable_operand (operands[3],
  2789.                       (32 - INTVAL (operands[1])) / 8);
  2790.   if (INTVAL (operands[1]) == 8)
  2791.     return \"move%.b %3,%0\";
  2792.   return \"move%.w %3,%0\";
  2793. }")
  2794.  
  2795. (define_insn ""
  2796.   [(set (match_operand:SI 0 "general_operand" "=&d")
  2797.     (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do")
  2798.              (match_operand:SI 2 "immediate_operand" "i")
  2799.              (match_operand:SI 3 "immediate_operand" "i")))]
  2800.   "TARGET_68020 && TARGET_BITFIELD
  2801.    && GET_CODE (operands[2]) == CONST_INT
  2802.    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
  2803.    && GET_CODE (operands[3]) == CONST_INT
  2804.    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
  2805.    && (GET_CODE (operands[1]) == REG
  2806.        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
  2807.   "*
  2808. {
  2809.   if (REG_P (operands[1]))
  2810.     {
  2811.       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
  2812.     return \"bfextu %1{%b3:%b2},%0\";
  2813.     }
  2814.   else
  2815.     operands[1]
  2816.       = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  2817.  
  2818.   output_asm_insn (\"clr%.l %0\", operands);
  2819.   if (GET_CODE (operands[0]) == MEM)
  2820.     operands[0] = adj_offsettable_operand (operands[0],
  2821.                       (32 - INTVAL (operands[1])) / 8);
  2822.   if (INTVAL (operands[2]) == 8)
  2823.     return \"move%.b %1,%0\";
  2824.   return \"move%.w %1,%0\";
  2825. }")
  2826.  
  2827. (define_insn ""
  2828.   [(set (match_operand:SI 0 "general_operand" "=d")
  2829.     (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do")
  2830.              (match_operand:SI 2 "immediate_operand" "i")
  2831.              (match_operand:SI 3 "immediate_operand" "i")))]
  2832.   "TARGET_68020 && TARGET_BITFIELD
  2833.    && GET_CODE (operands[2]) == CONST_INT
  2834.    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
  2835.    && GET_CODE (operands[3]) == CONST_INT
  2836.    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
  2837.    && (GET_CODE (operands[1]) == REG
  2838.        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
  2839.   "*
  2840. {
  2841.   if (REG_P (operands[1]))
  2842.     {
  2843.       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
  2844.     return \"bfexts %1{%b3:%b2},%0\";
  2845.     }
  2846.   else
  2847.     operands[1]
  2848.       = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  2849.  
  2850.   if (INTVAL (operands[2]) == 8)
  2851.     return \"move%.b %1,%0\;extb%.l %0\";
  2852.   return \"move%.w %1,%0\;ext%.l %0\";
  2853. }")
  2854.  
  2855. ;; Bit field instructions, general cases.
  2856. ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
  2857. ;; so that its address is reloaded.
  2858.  
  2859. (define_insn "extv"
  2860.   [(set (match_operand:SI 0 "general_operand" "=d,d")
  2861.     (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d")
  2862.              (match_operand:SI 2 "general_operand" "di,di")
  2863.              (match_operand:SI 3 "general_operand" "di,di")))]
  2864.   "TARGET_68020 && TARGET_BITFIELD"
  2865.   "bfexts %1{%b3:%b2},%0")
  2866.  
  2867. (define_insn "extzv"
  2868.   [(set (match_operand:SI 0 "general_operand" "=d,d")
  2869.     (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d")
  2870.              (match_operand:SI 2 "general_operand" "di,di")
  2871.              (match_operand:SI 3 "general_operand" "di,di")))]
  2872.   "TARGET_68020 && TARGET_BITFIELD"
  2873.   "bfextu %1{%b3:%b2},%0")
  2874.  
  2875. (define_insn ""
  2876.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  2877.              (match_operand:SI 1 "general_operand" "di,di")
  2878.              (match_operand:SI 2 "general_operand" "di,di"))
  2879.         (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
  2880.         (match_operand 3 "immediate_operand" "i,i")))]
  2881.   "TARGET_68020 && TARGET_BITFIELD
  2882.    && GET_CODE (operands[3]) == CONST_INT
  2883.    && (INTVAL (operands[3]) == -1
  2884.        || (GET_CODE (operands[1]) == CONST_INT
  2885.            && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
  2886.   "*
  2887. {
  2888.   CC_STATUS_INIT;
  2889.   return \"bfchg %0{%b2:%b1}\";
  2890. }")
  2891.  
  2892. (define_insn ""
  2893.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  2894.              (match_operand:SI 1 "general_operand" "di,di")
  2895.              (match_operand:SI 2 "general_operand" "di,di"))
  2896.     (const_int 0))]
  2897.   "TARGET_68020 && TARGET_BITFIELD"
  2898.   "*
  2899. {
  2900.   CC_STATUS_INIT;
  2901.   return \"bfclr %0{%b2:%b1}\";
  2902. }")
  2903.  
  2904. (define_insn ""
  2905.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  2906.              (match_operand:SI 1 "general_operand" "di,di")
  2907.              (match_operand:SI 2 "general_operand" "di,di"))
  2908.     (const_int -1))]
  2909.   "TARGET_68020 && TARGET_BITFIELD"
  2910.   "*
  2911. {
  2912.   CC_STATUS_INIT;
  2913.   return \"bfset %0{%b2:%b1}\";
  2914. }")
  2915.  
  2916. (define_insn "insv"
  2917.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  2918.              (match_operand:SI 1 "general_operand" "di,di")
  2919.              (match_operand:SI 2 "general_operand" "di,di"))
  2920.     (match_operand:SI 3 "general_operand" "d,d"))]
  2921.   "TARGET_68020 && TARGET_BITFIELD"
  2922.   "bfins %3,%0{%b2:%b1}")
  2923.  
  2924. ;; Now recognize bit field insns that operate on registers
  2925. ;; (or at least were intended to do so).
  2926.  
  2927. (define_insn ""
  2928.   [(set (match_operand:SI 0 "general_operand" "=d")
  2929.     (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d")
  2930.              (match_operand:SI 2 "general_operand" "di")
  2931.              (match_operand:SI 3 "general_operand" "di")))]
  2932.   "TARGET_68020 && TARGET_BITFIELD"
  2933.   "bfexts %1{%b3:%b2},%0")
  2934.  
  2935. (define_insn ""
  2936.   [(set (match_operand:SI 0 "general_operand" "=d")
  2937.     (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d")
  2938.              (match_operand:SI 2 "general_operand" "di")
  2939.              (match_operand:SI 3 "general_operand" "di")))]
  2940.   "TARGET_68020 && TARGET_BITFIELD"
  2941.   "bfextu %1{%b3:%b2},%0")
  2942.  
  2943. (define_insn ""
  2944.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  2945.              (match_operand:SI 1 "general_operand" "di")
  2946.              (match_operand:SI 2 "general_operand" "di"))
  2947.     (const_int 0))]
  2948.   "TARGET_68020 && TARGET_BITFIELD"
  2949.   "*
  2950. {
  2951.   CC_STATUS_INIT;
  2952.   return \"bfclr %0{%b2:%b1}\";
  2953. }")
  2954.  
  2955. (define_insn ""
  2956.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  2957.              (match_operand:SI 1 "general_operand" "di")
  2958.              (match_operand:SI 2 "general_operand" "di"))
  2959.     (const_int -1))]
  2960.   "TARGET_68020 && TARGET_BITFIELD"
  2961.   "*
  2962. {
  2963.   CC_STATUS_INIT;
  2964.   return \"bfset %0{%b2:%b1}\";
  2965. }")
  2966.  
  2967. (define_insn ""
  2968.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  2969.              (match_operand:SI 1 "general_operand" "di")
  2970.              (match_operand:SI 2 "general_operand" "di"))
  2971.     (match_operand:SI 3 "general_operand" "d"))]
  2972.   "TARGET_68020 && TARGET_BITFIELD"
  2973.   "*
  2974. {
  2975. #if 0
  2976.   /* These special cases are now recognized by a specific pattern.  */
  2977.   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
  2978.       && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
  2979.     return \"move%.w %3,%0\";
  2980.   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
  2981.       && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
  2982.     return \"move%.b %3,%0\";
  2983. #endif
  2984.   return \"bfins %3,%0{%b2:%b1}\";
  2985. }")
  2986.  
  2987. ;; Special patterns for optimizing bit-field instructions.
  2988.  
  2989. (define_insn ""
  2990.   [(set (cc0)
  2991.     (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
  2992.              (match_operand:SI 1 "general_operand" "di")
  2993.              (match_operand:SI 2 "general_operand" "di")))]
  2994.   "TARGET_68020 && TARGET_BITFIELD
  2995.    && GET_CODE (operands[1]) == CONST_INT"
  2996.   "*
  2997. {
  2998.   if (operands[1] == const1_rtx
  2999.       && GET_CODE (operands[2]) == CONST_INT)
  3000.     {    
  3001.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  3002.       return output_btst (operands,
  3003.               gen_rtx (CONST_INT, VOIDmode,
  3004.                    width - INTVAL (operands[2])),
  3005.               operands[0],
  3006.               insn, 1000);
  3007.       /* Pass 1000 as SIGNPOS argument so that btst will
  3008.          not think we are testing the sign bit for an `and'
  3009.      and assume that nonzero implies a negative result.  */
  3010.     }
  3011.   if (INTVAL (operands[1]) != 32)
  3012.     cc_status.flags = CC_NOT_NEGATIVE;
  3013.   return \"bftst %0{%b2:%b1}\";
  3014. }")
  3015.  
  3016. (define_insn ""
  3017.   [(set (cc0)
  3018.     (subreg:QI
  3019.      (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
  3020.               (match_operand:SI 1 "general_operand" "di")
  3021.               (match_operand:SI 2 "general_operand" "di"))
  3022.      0))]
  3023.   "TARGET_68020 && TARGET_BITFIELD
  3024.    && GET_CODE (operands[1]) == CONST_INT"
  3025.   "*
  3026. {
  3027.   if (operands[1] == const1_rtx
  3028.       && GET_CODE (operands[2]) == CONST_INT)
  3029.     {    
  3030.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  3031.       return output_btst (operands,
  3032.               gen_rtx (CONST_INT, VOIDmode,
  3033.                    width - INTVAL (operands[2])),
  3034.               operands[0],
  3035.               insn, 1000);
  3036.       /* Pass 1000 as SIGNPOS argument so that btst will
  3037.          not think we are testing the sign bit for an `and'
  3038.      and assume that nonzero implies a negative result.  */
  3039.     }
  3040.   if (INTVAL (operands[1]) != 32)
  3041.     cc_status.flags = CC_NOT_NEGATIVE;
  3042.   return \"bftst %0{%b2:%b1}\";
  3043. }")
  3044.  
  3045. (define_insn ""
  3046.   [(set (cc0)
  3047.     (subreg:HI
  3048.      (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
  3049.               (match_operand:SI 1 "general_operand" "di")
  3050.               (match_operand:SI 2 "general_operand" "di"))
  3051.      0))]
  3052.   "TARGET_68020 && TARGET_BITFIELD
  3053.    && GET_CODE (operands[1]) == CONST_INT"
  3054.   "*
  3055. {
  3056.   if (operands[1] == const1_rtx
  3057.       && GET_CODE (operands[2]) == CONST_INT)
  3058.     {    
  3059.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  3060.       return output_btst (operands,
  3061.               gen_rtx (CONST_INT, VOIDmode,
  3062.                    width - INTVAL (operands[2])),
  3063.               operands[0],
  3064.               insn, 1000);
  3065.       /* Pass 1000 as SIGNPOS argument so that btst will
  3066.          not think we are testing the sign bit for an `and'
  3067.      and assume that nonzero implies a negative result.  */
  3068.     }
  3069.   if (INTVAL (operands[1]) != 32)
  3070.     cc_status.flags = CC_NOT_NEGATIVE;
  3071.   return \"bftst %0{%b2:%b1}\";
  3072. }")
  3073.   
  3074. ;;; now handle the register cases
  3075. (define_insn ""
  3076.   [(set (cc0)
  3077.     (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "d")
  3078.              (match_operand:SI 1 "general_operand" "di")
  3079.              (match_operand:SI 2 "general_operand" "di")))]
  3080.   "TARGET_68020 && TARGET_BITFIELD
  3081.    && GET_CODE (operands[1]) == CONST_INT"
  3082.   "*
  3083. {
  3084.   if (operands[1] == const1_rtx
  3085.       && GET_CODE (operands[2]) == CONST_INT)
  3086.     {    
  3087.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  3088.       return output_btst (operands,
  3089.               gen_rtx (CONST_INT, VOIDmode,
  3090.                    width - INTVAL (operands[2])),
  3091.               operands[0],
  3092.               insn, 1000);
  3093.       /* Pass 1000 as SIGNPOS argument so that btst will
  3094.          not think we are testing the sign bit for an `and'
  3095.      and assume that nonzero implies a negative result.  */
  3096.     }
  3097.   if (INTVAL (operands[1]) != 32)
  3098.     cc_status.flags = CC_NOT_NEGATIVE;
  3099.   return \"bftst %0{%b2:%b1}\";
  3100. }")
  3101.  
  3102. (define_insn ""
  3103.   [(set (cc0)
  3104.     (subreg:QI
  3105.      (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "d")
  3106.               (match_operand:SI 1 "general_operand" "di")
  3107.               (match_operand:SI 2 "general_operand" "di"))
  3108.      0))]
  3109.   "TARGET_68020 && TARGET_BITFIELD
  3110.    && GET_CODE (operands[1]) == CONST_INT"
  3111.   "*
  3112. {
  3113.   if (operands[1] == const1_rtx
  3114.       && GET_CODE (operands[2]) == CONST_INT)
  3115.     {    
  3116.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  3117.       return output_btst (operands,
  3118.               gen_rtx (CONST_INT, VOIDmode,
  3119.                    width - INTVAL (operands[2])),
  3120.               operands[0],
  3121.               insn, 1000);
  3122.       /* Pass 1000 as SIGNPOS argument so that btst will
  3123.          not think we are testing the sign bit for an `and'
  3124.      and assume that nonzero implies a negative result.  */
  3125.     }
  3126.   if (INTVAL (operands[1]) != 32)
  3127.     cc_status.flags = CC_NOT_NEGATIVE;
  3128.   return \"bftst %0{%b2:%b1}\";
  3129. }")
  3130.  
  3131. (define_insn ""
  3132.   [(set (cc0)
  3133.     (subreg:HI
  3134.      (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "d")
  3135.               (match_operand:SI 1 "general_operand" "di")
  3136.               (match_operand:SI 2 "general_operand" "di"))
  3137.      0))]
  3138.   "TARGET_68020 && TARGET_BITFIELD
  3139.    && GET_CODE (operands[1]) == CONST_INT"
  3140.   "*
  3141. {
  3142.   if (operands[1] == const1_rtx
  3143.       && GET_CODE (operands[2]) == CONST_INT)
  3144.     {    
  3145.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  3146.       return output_btst (operands,
  3147.               gen_rtx (CONST_INT, VOIDmode,
  3148.                    width - INTVAL (operands[2])),
  3149.               operands[0],
  3150.               insn, 1000);
  3151.       /* Pass 1000 as SIGNPOS argument so that btst will
  3152.          not think we are testing the sign bit for an `and'
  3153.      and assume that nonzero implies a negative result.  */
  3154.     }
  3155.   if (INTVAL (operands[1]) != 32)
  3156.     cc_status.flags = CC_NOT_NEGATIVE;
  3157.   return \"bftst %0{%b2:%b1}\";
  3158. }")
  3159.  
  3160. (define_insn "seq"
  3161.   [(set (match_operand:QI 0 "general_operand" "=d")
  3162.     (eq (cc0) (const_int 0)))]
  3163.   ""
  3164.   "*
  3165.   cc_status = cc_prev_status;
  3166.   OUTPUT_JUMP (\"seq %0\", \"fseq %0\", \"seq %0\");
  3167. ")
  3168.  
  3169. (define_insn "sne"
  3170.   [(set (match_operand:QI 0 "general_operand" "=d")
  3171.     (ne (cc0) (const_int 0)))]
  3172.   ""
  3173.   "*
  3174.   cc_status = cc_prev_status;
  3175.   OUTPUT_JUMP (\"sne %0\", \"fsne %0\", \"sne %0\");
  3176. ")
  3177.  
  3178. (define_insn "sgt"
  3179.   [(set (match_operand:QI 0 "general_operand" "=d")
  3180.     (gt (cc0) (const_int 0)))]
  3181.   ""
  3182.   "*
  3183.   cc_status = cc_prev_status;
  3184.   OUTPUT_JUMP (\"sgt %0\", \"fsgt %0\", 0);
  3185. ")
  3186.  
  3187. (define_insn "sgtu"
  3188.   [(set (match_operand:QI 0 "general_operand" "=d")
  3189.     (gtu (cc0) (const_int 0)))]
  3190.   ""
  3191.   "* cc_status = cc_prev_status;
  3192.      return \"shi %0\"; ")
  3193.  
  3194. (define_insn "slt"
  3195.   [(set (match_operand:QI 0 "general_operand" "=d")
  3196.     (lt (cc0) (const_int 0)))]
  3197.   ""
  3198.   "* cc_status = cc_prev_status;
  3199.      OUTPUT_JUMP (\"slt %0\", \"fslt %0\", \"smi %0\"); ")
  3200.  
  3201. (define_insn "sltu"
  3202.   [(set (match_operand:QI 0 "general_operand" "=d")
  3203.     (ltu (cc0) (const_int 0)))]
  3204.   ""
  3205.   "* cc_status = cc_prev_status;
  3206.      return \"scs %0\"; ")
  3207.  
  3208. (define_insn "sge"
  3209.   [(set (match_operand:QI 0 "general_operand" "=d")
  3210.     (ge (cc0) (const_int 0)))]
  3211.   ""
  3212.   "* cc_status = cc_prev_status;
  3213.      OUTPUT_JUMP (\"sge %0\", \"fsge %0\", \"spl %0\"); ")
  3214.  
  3215. (define_insn "sgeu"
  3216.   [(set (match_operand:QI 0 "general_operand" "=d")
  3217.     (geu (cc0) (const_int 0)))]
  3218.   ""
  3219.   "* cc_status = cc_prev_status;
  3220.      return \"scc %0\"; ")
  3221.  
  3222. (define_insn "sle"
  3223.   [(set (match_operand:QI 0 "general_operand" "=d")
  3224.     (le (cc0) (const_int 0)))]
  3225.   ""
  3226.   "*
  3227.   cc_status = cc_prev_status;
  3228.   OUTPUT_JUMP (\"sle %0\", \"fsle %0\", 0);
  3229. ")
  3230.  
  3231. (define_insn "sleu"
  3232.   [(set (match_operand:QI 0 "general_operand" "=d")
  3233.     (leu (cc0) (const_int 0)))]
  3234.   ""
  3235.   "* cc_status = cc_prev_status;
  3236.      return \"sls %0\"; ")
  3237.  
  3238. ;; Basic conditional jump instructions.
  3239.  
  3240. (define_insn "beq"
  3241.   [(set (pc)
  3242.     (if_then_else (eq (cc0)
  3243.               (const_int 0))
  3244.               (label_ref (match_operand 0 "" ""))
  3245.               (pc)))]
  3246.   ""
  3247.   "*
  3248. {
  3249.   OUTPUT_JUMP (\"beq %l0\", \"fbeq %l0\", \"beq %l0\");
  3250. }")
  3251.  
  3252. (define_insn "bne"
  3253.   [(set (pc)
  3254.     (if_then_else (ne (cc0)
  3255.               (const_int 0))
  3256.               (label_ref (match_operand 0 "" ""))
  3257.               (pc)))]
  3258.   ""
  3259.   "*
  3260. {
  3261.   OUTPUT_JUMP (\"bne %l0\", \"fbne %l0\", \"bne %l0\");
  3262. }")
  3263.  
  3264. (define_insn "bgt"
  3265.   [(set (pc)
  3266.     (if_then_else (gt (cc0)
  3267.               (const_int 0))
  3268.               (label_ref (match_operand 0 "" ""))
  3269.               (pc)))]
  3270.   ""
  3271.   "*
  3272.   OUTPUT_JUMP (\"bgt %l0\", \"fbgt %l0\", 0);
  3273. ")
  3274.  
  3275. (define_insn "bgtu"
  3276.   [(set (pc)
  3277.     (if_then_else (gtu (cc0)
  3278.                (const_int 0))
  3279.               (label_ref (match_operand 0 "" ""))
  3280.               (pc)))]
  3281.   ""
  3282.   "*
  3283.   return \"bhi %l0\";
  3284. ")
  3285.  
  3286. (define_insn "blt"
  3287.   [(set (pc)
  3288.     (if_then_else (lt (cc0)
  3289.               (const_int 0))
  3290.               (label_ref (match_operand 0 "" ""))
  3291.               (pc)))]
  3292.   ""
  3293.   "*
  3294.   OUTPUT_JUMP (\"blt %l0\", \"fblt %l0\", \"bmi %l0\");
  3295. ")
  3296.  
  3297. (define_insn "bltu"
  3298.   [(set (pc)
  3299.     (if_then_else (ltu (cc0)
  3300.                (const_int 0))
  3301.               (label_ref (match_operand 0 "" ""))
  3302.               (pc)))]
  3303.   ""
  3304.   "*
  3305.   return \"bcs %l0\";
  3306. ")
  3307.  
  3308. (define_insn "bge"
  3309.   [(set (pc)
  3310.     (if_then_else (ge (cc0)
  3311.               (const_int 0))
  3312.               (label_ref (match_operand 0 "" ""))
  3313.               (pc)))]
  3314.   ""
  3315.   "*
  3316.   OUTPUT_JUMP (\"bge %l0\", \"fbge %l0\", \"bpl %l0\");
  3317. ")
  3318.  
  3319. (define_insn "bgeu"
  3320.   [(set (pc)
  3321.     (if_then_else (geu (cc0)
  3322.                (const_int 0))
  3323.               (label_ref (match_operand 0 "" ""))
  3324.               (pc)))]
  3325.   ""
  3326.   "*
  3327.   return \"bcc %l0\";
  3328. ")
  3329.  
  3330. (define_insn "ble"
  3331.   [(set (pc)
  3332.     (if_then_else (le (cc0)
  3333.               (const_int 0))
  3334.               (label_ref (match_operand 0 "" ""))
  3335.               (pc)))]
  3336.   ""
  3337.   "*
  3338.   OUTPUT_JUMP (\"ble %l0\", \"fble %l0\", 0);
  3339. ")
  3340.  
  3341. (define_insn "bleu"
  3342.   [(set (pc)
  3343.     (if_then_else (leu (cc0)
  3344.                (const_int 0))
  3345.               (label_ref (match_operand 0 "" ""))
  3346.               (pc)))]
  3347.   ""
  3348.   "*
  3349.   return \"bls %l0\";
  3350. ")
  3351.  
  3352. ;; Negated conditional jump instructions.
  3353.  
  3354. (define_insn ""
  3355.   [(set (pc)
  3356.     (if_then_else (eq (cc0)
  3357.               (const_int 0))
  3358.               (pc)
  3359.               (label_ref (match_operand 0 "" ""))))]
  3360.   ""
  3361.   "*
  3362. {
  3363.   OUTPUT_JUMP (\"bne %l0\", \"fbne %l0\", \"bne %l0\");
  3364. }")
  3365.  
  3366. (define_insn ""
  3367.   [(set (pc)
  3368.     (if_then_else (ne (cc0)
  3369.               (const_int 0))
  3370.               (pc)
  3371.               (label_ref (match_operand 0 "" ""))))]
  3372.   ""
  3373.   "*
  3374. {
  3375.   OUTPUT_JUMP (\"beq %l0\", \"fbeq %l0\", \"beq %l0\");
  3376. }")
  3377.  
  3378. (define_insn ""
  3379.   [(set (pc)
  3380.     (if_then_else (gt (cc0)
  3381.               (const_int 0))
  3382.               (pc)
  3383.               (label_ref (match_operand 0 "" ""))))]
  3384.   ""
  3385.   "*
  3386.   OUTPUT_JUMP (\"ble %l0\", \"fbngt %l0\", 0);
  3387. ")
  3388.  
  3389. (define_insn ""
  3390.   [(set (pc)
  3391.     (if_then_else (gtu (cc0)
  3392.                (const_int 0))
  3393.               (pc)
  3394.               (label_ref (match_operand 0 "" ""))))]
  3395.   ""
  3396.   "*
  3397.   return \"bls %l0\";
  3398. ")
  3399.  
  3400. (define_insn ""
  3401.   [(set (pc)
  3402.     (if_then_else (lt (cc0)
  3403.               (const_int 0))
  3404.               (pc)
  3405.               (label_ref (match_operand 0 "" ""))))]
  3406.   ""
  3407.   "*
  3408.   OUTPUT_JUMP (\"bge %l0\", \"fbnlt %l0\", \"bpl %l0\");
  3409. ")
  3410.  
  3411. (define_insn ""
  3412.   [(set (pc)
  3413.     (if_then_else (ltu (cc0)
  3414.                (const_int 0))
  3415.               (pc)
  3416.               (label_ref (match_operand 0 "" ""))))]
  3417.   ""
  3418.   "*
  3419.   return \"bcc %l0\";
  3420. ")
  3421.  
  3422. (define_insn ""
  3423.   [(set (pc)
  3424.     (if_then_else (ge (cc0)
  3425.               (const_int 0))
  3426.               (pc)
  3427.               (label_ref (match_operand 0 "" ""))))]
  3428.   ""
  3429.   "*
  3430.   OUTPUT_JUMP (\"blt %l0\", \"fbnge %l0\", \"bmi %l0\");
  3431. ")
  3432.  
  3433. (define_insn ""
  3434.   [(set (pc)
  3435.     (if_then_else (geu (cc0)
  3436.                (const_int 0))
  3437.               (pc)
  3438.               (label_ref (match_operand 0 "" ""))))]
  3439.   ""
  3440.   "*
  3441.   return \"bcs %l0\";
  3442. ")
  3443.  
  3444. (define_insn ""
  3445.   [(set (pc)
  3446.     (if_then_else (le (cc0)
  3447.               (const_int 0))
  3448.               (pc)
  3449.               (label_ref (match_operand 0 "" ""))))]
  3450.   ""
  3451.   "*
  3452.   OUTPUT_JUMP (\"bgt %l0\", \"fbnle %l0\", 0);
  3453. ")
  3454.  
  3455. (define_insn ""
  3456.   [(set (pc)
  3457.     (if_then_else (leu (cc0)
  3458.                (const_int 0))
  3459.               (pc)
  3460.               (label_ref (match_operand 0 "" ""))))]
  3461.   ""
  3462.   "*
  3463.   return \"bhi %l0\";
  3464. ")
  3465.  
  3466. ;; Subroutines of "casesi".
  3467.  
  3468. (define_expand "casesi_1"
  3469.   [(set (match_operand:SI 3 "general_operand" "")
  3470.     (plus:SI (match_operand:SI 0 "general_operand" "")
  3471.          ;; Note operand 1 has been negated!
  3472.          (match_operand:SI 1 "immediate_operand" "")))
  3473.    (set (cc0) (compare (match_operand:SI 2 "general_operand" "")
  3474.                (match_dup 3)))
  3475.    (set (pc) (if_then_else (ltu (cc0) (const_int 0))
  3476.                (label_ref (match_operand 4 "" "")) (pc)))]
  3477.   ""
  3478.   "")
  3479.  
  3480. (define_expand "casesi_2"
  3481.   [(set (match_operand:SI 0 "" "") (mem:HI (match_operand:SI 1 "" "")))
  3482.    ;; The USE here is so that at least one jump-insn will refer to the label,
  3483.    ;; to keep it alive in jump_optimize.
  3484.    (parallel [(set (pc)
  3485.            (plus:SI (pc) (match_dup 0)))
  3486.           (use (label_ref (match_operand 2 "" "")))])]
  3487.   ""
  3488.   "")
  3489.  
  3490. ;; Operand 0 is index (in bytes); operand 1 is minimum, operand 2 themaximum;
  3491. ;; operand 3 is CODE_LABEL for the table;
  3492. ;; operand 4 is the CODE_LABEL to go to if index out of range.
  3493. (define_expand "casesi"
  3494.   ;; We don't use these for generating the RTL, but we must describe
  3495.   ;; the operands here.
  3496.   [(match_operand:SI 0 "general_operand" "")
  3497.    (match_operand:SI 1 "immediate_operand" "")
  3498.    (match_operand:SI 2 "general_operand" "")
  3499.    (match_operand 3 "" "")
  3500.    (match_operand 4 "" "")]
  3501.   ""
  3502.   "
  3503. {
  3504.   rtx table_elt_addr;
  3505.   rtx index_diff;
  3506.  
  3507.   operands[1] = negate_rtx (SImode, operands[1]);
  3508.   index_diff = gen_reg_rtx (SImode);
  3509.   /* Emit the first few insns.  */
  3510.   emit_insn (gen_casesi_1 (operands[0], operands[1], operands[2],
  3511.                index_diff, operands[4]));
  3512.   /* Construct a memory address.  This may emit some insns.  */
  3513.   table_elt_addr
  3514.     = memory_address_noforce
  3515.         (HImode,
  3516.      gen_rtx (PLUS, Pmode,
  3517.           gen_rtx (MULT, Pmode, index_diff,
  3518.                gen_rtx (CONST_INT, VOIDmode, 2)),
  3519.           gen_rtx (LABEL_REF, VOIDmode, operands[3])));
  3520.   /* Emit the last few insns.  */
  3521.   emit_insn (gen_casesi_2 (gen_reg_rtx (HImode), table_elt_addr, operands[3]));
  3522.   DONE;
  3523. }")
  3524.  
  3525. ;; Recognize one of the insns resulting from casesi_2.
  3526. (define_insn ""
  3527.   [(set (pc)
  3528.     (plus:SI (pc) (match_operand:HI 0 "general_operand" "r")))
  3529.    (use (label_ref (match_operand 1 "" "")))]
  3530.   ""
  3531.   "*
  3532.   return TARGET_GAS?\"jmp @(%l1,%0:w)\":\"jmp %l1(%0.w)\";
  3533. ")
  3534.  
  3535. ;; Unconditional and other jump instructions
  3536. (define_insn "jump"
  3537.   [(set (pc)
  3538.     (label_ref (match_operand 0 "" "")))]
  3539.   ""
  3540.   "*
  3541.   return \"bra %l0\";
  3542. ")
  3543.  
  3544. (define_insn ""
  3545.   [(set (pc)
  3546.     (if_then_else
  3547.      (ne (compare (plus:HI (match_operand:HI 0 "general_operand" "g")
  3548.                    (const_int -1))
  3549.               (const_int -1))
  3550.          (const_int 0))
  3551.      (label_ref (match_operand 1 "" ""))
  3552.      (pc)))
  3553.    (set (match_dup 0)
  3554.     (plus:HI (match_dup 0)
  3555.          (const_int -1)))]
  3556.   ""
  3557.   "*
  3558. {
  3559.   if (DATA_REG_P (operands[0]))
  3560.     return \"dbra %0,%l1\";
  3561.   if (GET_CODE (operands[0]) == MEM)
  3562.     {
  3563.       return \"subq%.w #1,%0\;bcc %l1\";
  3564.     }
  3565.   return \"subq%.w #1,%0\;cmp%.w #-1,%0\;bne %l1\";
  3566. }")
  3567.  
  3568. (define_insn ""
  3569.   [(set (pc)
  3570.     (if_then_else
  3571.      (ne (compare (plus:SI (match_operand:SI 0 "general_operand" "g")
  3572.                    (const_int -1))
  3573.               (const_int -1))
  3574.          (const_int 0))
  3575.      (label_ref (match_operand 1 "" ""))
  3576.      (pc)))
  3577.    (set (match_dup 0)
  3578.     (plus:SI (match_dup 0)
  3579.          (const_int -1)))]
  3580.   ""
  3581.   "*
  3582. {
  3583.   if (DATA_REG_P (operands[0]))
  3584.     return \"dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;bcc %l1\";
  3585.   if (GET_CODE (operands[0]) == MEM)
  3586.     return \"subq%.l #1,%0\;bcc %l1\";
  3587.   return \"subq%.l #1,%0\;cmp%.l #-1,%0\;bne %l1\";
  3588. }")
  3589.  
  3590. ;; dbra patterns that use REG_NOTES info generated by strength_reduce.
  3591.  
  3592. (define_insn ""
  3593.   [(set (pc)
  3594.     (if_then_else
  3595.       (ge (plus:SI (match_operand:SI 0 "general_operand" "g")
  3596.             (const_int -1))
  3597.           (const_int 0))
  3598.       (label_ref (match_operand 1 "" ""))
  3599.       (pc)))
  3600.    (set (match_dup 0)
  3601.     (plus:SI (match_dup 0)
  3602.          (const_int -1)))]
  3603.   "find_reg_note (insn, REG_NONNEG, 0)"
  3604.   "*
  3605. {
  3606.   if (DATA_REG_P (operands[0]))
  3607.     return \"dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;bcc %l1\";
  3608.   if (GET_CODE (operands[0]) == MEM)
  3609.     return \"subq%.l #1,%0\;bcc %l1\";
  3610.   return \"subq%.l #1,%0\;cmp%.l #-1,%0\;bne %l1\";
  3611. }")
  3612.  
  3613. ;; Call subroutine with no return value.
  3614. (define_insn "call"
  3615.   [(call (match_operand:QI 0 "general_operand" "o")
  3616.      (match_operand:SI 1 "general_operand" "g"))]
  3617.   ;; Operand 1 not really used on the m68000.
  3618.   ""
  3619.   "*
  3620. {
  3621.   char *name = \"?\";
  3622.   if (GET_CODE(operands[0])!=REG)
  3623.         {
  3624.         rtx sym = XEXP (operands[0], 0);
  3625.         if (sym && (GET_CODE(sym) == SYMBOL_REF)) name = XSTR (sym, 0);
  3626.         }
  3627.   if (name[1] == ';')
  3628.     {
  3629.       operands[0] = gen_rtx (MEM, QImode,
  3630.                  gen_rtx (SYMBOL_REF, SImode, name+2));
  3631.       return TARGET_GAS?\".word %0\":\"DC.W %0\";
  3632.     }
  3633.   if (TARGET_FX30 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
  3634.     {
  3635.       return \"DC.W $61ff ; bsr.l\;DC.L %0-m#start-*\";
  3636.     }
  3637.   return \"jsr %0\";
  3638. }")
  3639.  
  3640. ;; Call subroutine, returning value in operand 0
  3641. ;; (which must be a hard register).
  3642. (define_insn "call_value"
  3643.   [(set (match_operand 0 "" "rf")
  3644.     (call (match_operand:QI 1 "general_operand" "o")
  3645.           (match_operand:SI 2 "general_operand" "g")))]
  3646.   ;; Operand 2 not really used on the m68000.
  3647.   ""
  3648.   "*
  3649. {
  3650.   char *name = \"?\";
  3651.   if (GET_CODE(operands[1])!=REG)
  3652.         {
  3653.         rtx sym = XEXP (operands[1], 0);
  3654.         if (sym && (GET_CODE(sym) == SYMBOL_REF)) name = XSTR (sym, 0);
  3655.         }
  3656.   if (name[1] == ';') {
  3657.     operands[1] = gen_rtx (MEM, QImode, gen_rtx (SYMBOL_REF, SImode, name+2));
  3658.     return TARGET_GAS?\".word %1\":\"DC.W %1\";
  3659.   }
  3660.   if (TARGET_FX30 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
  3661.     {
  3662.       return \"DC.W $61ff ; bsr.l\;DC.L %1-m#start-*\";
  3663.     }
  3664.   return \"jsr %1\";
  3665. }")
  3666.  
  3667. (define_insn "return"
  3668.   [(return)]
  3669.   "0"
  3670.   "ret 0")
  3671.  
  3672. (define_insn "nop"
  3673.   [(const_int 0)]
  3674.   ""
  3675.   "nop")
  3676.  
  3677. ;; This should not be used unless the add/sub insns can't be.
  3678.  
  3679. (define_insn ""
  3680.   [(set (match_operand:SI 0 "general_operand" "=a")
  3681.     (match_operand:QI 1 "address_operand" "p"))]
  3682.   ""
  3683.   "lea %a1,%0")
  3684.  
  3685. ;; This is the first machine-dependent peephole optimization.
  3686. ;; It is useful when a floating value is returned from a function call
  3687. ;; and then is moved into an FP register.
  3688. ;; But it is mainly intended to test the support for these optimizations.
  3689.  
  3690. (define_peephole
  3691.   [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
  3692.    (set (match_operand:DF 0 "register_operand" "f")
  3693.     (match_operand:DF 1 "register_operand" "ad"))]
  3694.   "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
  3695.   "*
  3696. {
  3697.   rtx xoperands[2];
  3698.   xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  3699.   output_asm_insn (\"move%.l %1,%@\", xoperands);
  3700.   output_asm_insn (\"move%.l %1,%-\", operands);
  3701.   return \"fmove%.d %+,%0\";
  3702. }
  3703. ")
  3704.  
  3705.  
  3706. ;;- Local variables:
  3707. ;;- mode:emacs-lisp
  3708. ;;- comment-start: ";;- "
  3709. ;;- comment-start-skip: ";+- *"
  3710. ;;- eval: (set-syntax-table (copy-sequence (syntax-table)))
  3711. ;;- eval: (modify-syntax-entry ?[ "(]")
  3712. ;;- eval: (modify-syntax-entry ?] ")[")
  3713. ;;- eval: (modify-syntax-entry ?{ "(}")
  3714. ;;- eval: (modify-syntax-entry ?} "){")
  3715. ;;- End:
  3716.